1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-02-02 15:09:23 -05:00

[mujs] nodelist.forEach passes test case

This commit is contained in:
Witold Filipczyk 2024-05-07 19:33:34 +02:00
parent 7748eb5ab9
commit a9ae51ae9f
2 changed files with 7 additions and 4 deletions

View File

@ -88,9 +88,10 @@ mjs_nodeList_set_items(js_State *J, void *node)
continue;
}
mjs_push_element(J, element);
js_setindex(J, 1, i);
js_setindex(J, -2, i);
dom_node_unref(element);
}
js_setlength(J, -1, length);
}
static void
@ -138,10 +139,10 @@ mjs_push_nodelist(js_State *J, void *node)
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
js_newobject(J);
js_newarray(J);
{
js_newuserdata(J, "nodelist", node, mjs_nodeList_finalizer);
addproperty(J, "length", mjs_nodeList_get_property_length, NULL);
// addproperty(J, "length", mjs_nodeList_get_property_length, NULL);
addmethod(J, "item", mjs_nodeList_item, 1);
addmethod(J, "toString", mjs_nodeList_toString, 0);
mjs_nodeList_set_items(J, node);

View File

@ -9,11 +9,13 @@
console.error('nodelist.forEach.html');
var birds = document.querySelectorAll('li');
console.assert(birds.length === 3, birds.length);
var counter = 0;
birds.forEach(function(b) {
counter++;
});
console.assert(counter === 3, 'Three');
console.assert(counter === 3, counter);
console.exit(0);