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:
parent
c5a1296200
commit
28127b29b4
@ -2095,15 +2095,17 @@ htmlCollection_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId
|
|||||||
return htmlCollection_item2(ctx, hobj, index, hvp);
|
return htmlCollection_item2(ctx, hobj, index, hvp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (JSID_IS_STRING(id)) {
|
if (JSID_IS_STRING(id)) {
|
||||||
JS::RootedValue r_idval(ctx, idval);
|
JS::RootedValue r_idval(ctx, idval);
|
||||||
JS_IdToValue(ctx, id, &r_idval);
|
JS_IdToValue(ctx, id, &r_idval);
|
||||||
char *string = JS_EncodeString(ctx, r_idval.toString());
|
char *string = JS_EncodeString(ctx, r_idval.toString());
|
||||||
|
|
||||||
return htmlCollection_namedItem2(ctx, hobj, string, hvp);
|
std::string test = string;
|
||||||
|
|
||||||
|
if (test != "item" && test != "namedItem") {
|
||||||
|
return htmlCollection_namedItem2(ctx, hobj, string, hvp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return JS_PropertyStub(ctx, hobj, hid, hvp);
|
return JS_PropertyStub(ctx, hobj, hid, hvp);
|
||||||
}
|
}
|
||||||
|
23
test/ecmascript/namedItem.html
Normal file
23
test/ecmascript/namedItem.html
Normal 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>
|
Loading…
Reference in New Issue
Block a user