mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
[mujs] More dom_node_unref after mjs_push_element.
Similar cases to quickjs.
This commit is contained in:
parent
432edc6f65
commit
ff81eaa220
@ -190,6 +190,7 @@ mjs_htmlCollection_set_items(js_State *J, void *node)
|
||||
continue;
|
||||
}
|
||||
mjs_push_element(J, element);
|
||||
dom_node_unref(element);
|
||||
js_setindex(J, -2, counter);
|
||||
err = dom_element_get_attribute(element, corestring_dom_id, &name);
|
||||
|
||||
@ -204,6 +205,7 @@ mjs_htmlCollection_set_items(js_State *J, void *node)
|
||||
goto next;
|
||||
}
|
||||
mjs_push_element(J, element);
|
||||
dom_node_unref(element);
|
||||
js_setproperty(J, -2, dom_string_data(name));
|
||||
js_endtry(J);
|
||||
}
|
||||
@ -213,7 +215,6 @@ next:
|
||||
if (name) {
|
||||
dom_string_unref(name);
|
||||
}
|
||||
dom_node_unref(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,6 +178,7 @@ mjs_document_get_property_body(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, body);
|
||||
dom_node_unref(body);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -344,6 +345,7 @@ mjs_document_get_property_documentElement(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, root);
|
||||
dom_node_unref(root);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1091,6 +1093,7 @@ mjs_document_createComment(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, comment);
|
||||
dom_node_unref(comment);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1113,6 +1116,7 @@ mjs_document_createDocumentFragment(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, fragment);
|
||||
dom_node_unref(fragment);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1145,6 +1149,7 @@ mjs_document_createElement(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, element);
|
||||
dom_node_unref(element);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1177,6 +1182,7 @@ mjs_document_createTextNode(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, text_node);
|
||||
dom_node_unref(text_node);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1214,6 +1220,7 @@ mjs_document_getElementById(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, element);
|
||||
dom_node_unref(element);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1355,6 +1362,7 @@ mjs_document_querySelector(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, ret);
|
||||
dom_node_unref(ret);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -520,6 +520,7 @@ mjs_element_get_property_firstChild(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, node);
|
||||
dom_node_unref(node);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -566,6 +567,7 @@ mjs_element_get_property_firstElementChild(js_State *J)
|
||||
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
|
||||
dom_nodelist_unref(nodes);
|
||||
mjs_push_element(J, child);
|
||||
dom_node_unref(child);
|
||||
return;
|
||||
}
|
||||
dom_node_unref(child);
|
||||
@ -681,6 +683,7 @@ mjs_element_get_property_lastChild(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, last_child);
|
||||
dom_node_unref(last_child);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -726,6 +729,7 @@ mjs_element_get_property_lastElementChild(js_State *J)
|
||||
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
|
||||
dom_nodelist_unref(nodes);
|
||||
mjs_push_element(J, child);
|
||||
dom_node_unref(child);
|
||||
return;
|
||||
}
|
||||
dom_node_unref(child);
|
||||
@ -767,6 +771,7 @@ mjs_element_get_property_nextElementSibling(js_State *J)
|
||||
|
||||
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
|
||||
mjs_push_element(J, next);
|
||||
dom_node_unref(next);
|
||||
return;
|
||||
}
|
||||
prev_next = next;
|
||||
@ -867,6 +872,7 @@ mjs_element_get_property_nextSibling(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, node);
|
||||
dom_node_unref(node);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -966,6 +972,7 @@ mjs_element_get_property_offsetParent(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, node);
|
||||
dom_node_unref(node);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -1076,6 +1083,7 @@ mjs_element_get_property_parentElement(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, node);
|
||||
dom_node_unref(node);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1099,6 +1107,7 @@ mjs_element_get_property_parentNode(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, node);
|
||||
dom_node_unref(node);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1134,6 +1143,7 @@ mjs_element_get_property_previousElementSibling(js_State *J)
|
||||
|
||||
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
|
||||
mjs_push_element(J, prev);
|
||||
dom_node_unref(prev);
|
||||
return;
|
||||
}
|
||||
prev_prev = prev;
|
||||
@ -1163,6 +1173,7 @@ mjs_element_get_property_previousSibling(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, node);
|
||||
dom_node_unref(node);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2198,6 +2209,7 @@ mjs_element_appendChild(js_State *J)
|
||||
if (exc == DOM_NO_ERR && res) {
|
||||
interpreter->changed = 1;
|
||||
mjs_push_element(J, res);
|
||||
dom_node_unref(res);
|
||||
return;
|
||||
}
|
||||
js_pushnull(J);
|
||||
@ -2290,6 +2302,7 @@ mjs_element_cloneNode(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, clone);
|
||||
dom_node_unref(clone);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -2372,6 +2385,7 @@ mjs_element_closest(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, res);
|
||||
dom_node_unref(res);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2707,6 +2721,7 @@ mjs_element_insertBefore(js_State *J)
|
||||
}
|
||||
interpreter->changed = 1;
|
||||
mjs_push_element(J, spare);
|
||||
dom_node_unref(spare);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2808,6 +2823,7 @@ mjs_element_querySelector(js_State *J)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, ret);
|
||||
dom_node_unref(ret);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2928,6 +2944,7 @@ mjs_element_removeChild(js_State *J)
|
||||
if (exc == DOM_NO_ERR && spare) {
|
||||
interpreter->changed = 1;
|
||||
mjs_push_element(J, spare);
|
||||
dom_node_unref(spare);
|
||||
return;
|
||||
}
|
||||
js_pushnull(J);
|
||||
@ -3049,7 +3066,7 @@ mjs_element_finalizer(js_State *J, void *priv)
|
||||
}
|
||||
free_list(el_private->listeners);
|
||||
|
||||
if (node->refcnt > 0) {
|
||||
if (node && (node->refcnt > 0)) {
|
||||
dom_node_unref(node);
|
||||
}
|
||||
if (el_private->thisval) {
|
||||
@ -3067,6 +3084,7 @@ mjs_push_element(js_State *J, void *node)
|
||||
{
|
||||
struct mjs_element_private *el_private = NULL;
|
||||
|
||||
#if 0
|
||||
void *second = attr_find_in_map(map_privates, node);
|
||||
|
||||
if (second) {
|
||||
@ -3078,6 +3096,7 @@ mjs_push_element(js_State *J, void *node)
|
||||
el_private->ref_count++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!el_private) {
|
||||
el_private = (struct mjs_element_private *)mem_calloc(1, sizeof(*el_private));
|
||||
@ -3091,6 +3110,7 @@ mjs_push_element(js_State *J, void *node)
|
||||
el_private->interpreter = interpreter;
|
||||
el_private->node = node;
|
||||
el_private->ref_count = 1;
|
||||
dom_node_ref((dom_node *)node);
|
||||
|
||||
attr_save_in_map(map_privates, node, el_private);
|
||||
attr_save_in_map(map_elements, el_private, node);
|
||||
|
@ -48,6 +48,7 @@ mjs_push_nodeList2_item2(js_State *J, int idx)
|
||||
return;
|
||||
}
|
||||
mjs_push_element(J, sn->node);
|
||||
dom_node_unref(sn->node);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -77,6 +78,7 @@ mjs_nodeList2_set_items(js_State *J, void *nodes)
|
||||
|
||||
foreach (sn, *sni) {
|
||||
mjs_push_element(J, sn->node);
|
||||
dom_node_unref(sn->node);
|
||||
js_setindex(J, -2, i);
|
||||
i++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user