mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
[mujs] Modified Element.closest
This commit is contained in:
parent
9ed2c152fa
commit
63579d4b75
@ -2493,6 +2493,13 @@ mjs_element_closest(js_State *J)
|
||||
return;
|
||||
}
|
||||
|
||||
if (el) {
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
dom_node_ref(el);
|
||||
}
|
||||
|
||||
while (el) {
|
||||
res = el_match_selector(selector, el);
|
||||
|
||||
@ -2504,9 +2511,14 @@ mjs_element_closest(js_State *J)
|
||||
}
|
||||
dom_node *node = NULL;
|
||||
exc = dom_node_get_parent_node(el, &node);
|
||||
|
||||
if (exc != DOM_NO_ERR || !node) {
|
||||
break;
|
||||
}
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
dom_node_unref(el);
|
||||
el = node;
|
||||
}
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
@ -2514,6 +2526,13 @@ fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
dom_node_unref(root);
|
||||
|
||||
if (el) {
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
|
||||
#endif
|
||||
dom_node_unref(el);
|
||||
}
|
||||
|
||||
if (!res) {
|
||||
js_pushnull(J);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user