From e6bf26fa3103c41fd47e59a22c876635a85f4823 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Wed, 24 Jul 2024 20:37:36 +0200 Subject: [PATCH] [quickjs] lastChild, nextSibling --- src/ecmascript/quickjs/element.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/ecmascript/quickjs/element.c b/src/ecmascript/quickjs/element.c index d2b61c403..ad12e7425 100644 --- a/src/ecmascript/quickjs/element.c +++ b/src/ecmascript/quickjs/element.c @@ -794,9 +794,10 @@ js_element_get_property_lastChild(JSContext *ctx, JSValueConst this_val) //dom_node_unref(el); return JS_NULL; } - //dom_node_unref(el); + JSValue rr = getElement(ctx, last_child); + dom_node_unref(last_child); - return getElement(ctx, last_child); + return rr; } static JSValue @@ -843,8 +844,9 @@ js_element_get_property_lastElementChild(JSContext *ctx, JSValueConst this_val) if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) { dom_nodelist_unref(nodes); - //dom_node_unref(el); - return getElement(ctx, child); + JSValue rr = getElement(ctx, child); + dom_node_unref(child); + return rr; } dom_node_unref(child); } @@ -887,8 +889,9 @@ js_element_get_property_nextElementSibling(JSContext *ctx, JSValueConst this_val exc = dom_node_get_node_type(next, &type); if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) { - //dom_node_unref(el); - return getElement(ctx, next); + JSValue rr = getElement(ctx, next); + dom_node_unref(next); + return rr; } prev_next = next; node = next; @@ -1010,8 +1013,10 @@ js_element_get_property_nextSibling(JSContext *ctx, JSValueConst this_val) return JS_NULL; } //dom_node_unref(el); + JSValue rr = getElement(ctx, node); + dom_node_unref(node); - return getElement(ctx, node); + return rr; } #if 0