-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get property by index #45
Comments
Do you mean something like |
I don't know. getElementsByTagName(...) returns some object. and now I want to code somehow class for this object, so it can be accessed by index. In mozjs52 I had: static bool
htmlCollection_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp)
{
jsid id = hid.get();
...
if (JSID_IS_INT(id)) {
JS::RootedValue r_idval(ctx, idval);
JS_IdToValue(ctx, id, &r_idval);
int index = r_idval.toInt32();
return htmlCollection_item2(ctx, hobj, index, hvp);
}
...
}
JSClassOps htmlCollection_ops = {
JS_PropertyStub, nullptr,
htmlCollection_get_property, JS_StrictPropertyStub,
...
}; but AFAIK, in mozjs78 there is no getProperty in JSClassOps. |
Right, getProperty and setProperty were removed from JSClassOps. You will either have to use lazy property resolution (example https://github.com/mozilla-spidermonkey/spidermonkey-embedding-examples/blob/esr78/examples/resolve.cpp) or pre-define the properties. |
In mozjs52 JSClass had method getProperty. Newer versions have not. Could you add an example how to properly access elements by index?
For example getElementsByTagName() returns array. a = document.getElementsByTagName("H1")[5];
The text was updated successfully, but these errors were encountered: