1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[js] Try to rewrite htmlCollection get_property.

This commit is contained in:
Witold Filipczyk 2021-05-21 20:46:27 +02:00
parent c5a1296200
commit 28127b29b4
2 changed files with 28 additions and 3 deletions

View File

@ -2095,15 +2095,17 @@ htmlCollection_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId
return htmlCollection_item2(ctx, hobj, index, hvp);
}
#if 0
if (JSID_IS_STRING(id)) {
JS::RootedValue r_idval(ctx, idval);
JS_IdToValue(ctx, id, &r_idval);
char *string = JS_EncodeString(ctx, r_idval.toString());
std::string test = string;
if (test != "item" && test != "namedItem") {
return htmlCollection_namedItem2(ctx, hobj, string, hvp);
}
#endif
}
return JS_PropertyStub(ctx, hobj, hid, hvp);
}

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<body>
<h1>HTMLCollection namedItem() Method</h1>
<p id="myElement">The namedItem() method returns the element with the specified ID or name.</p>
<p>This example uses a shorthand method for the namedItem() method</p>
<p>Click the button to return the content of the P element with ID "myElement":</p>
<button onclick="myFunction()">Alert innerHTML of P</button>
<script>
function myFunction() {
var x = document.getElementsByTagName("P")["myElement"];
alert(x.innerHTML);
}
</script>
</body>
</html>