diff --git a/src/ecmascript/quickjs/element.c b/src/ecmascript/quickjs/element.c index 92e075b66..61b147d7d 100644 --- a/src/ecmascript/quickjs/element.c +++ b/src/ecmascript/quickjs/element.c @@ -2897,14 +2897,18 @@ js_element_contains(JSContext *ctx, JSValueConst this_val, int argc, JSValueCons dom_node *el = (dom_node *)(js_getopaque(this_val, js_element_class_id)); if (!el) { - return JS_FALSE; + return JS_EXCEPTION; } //dom_node_ref(el); - dom_node *el2 = (dom_node *)(js_getopaque(argv[0], js_element_class_id)); + dom_node *el2 = NULL; + + if (!JS_IsNull(argv[0])) { + el2 = (dom_node *)(js_getopaque(argv[0], js_element_class_id)); + } if (!el2) { //dom_node_unref(el); - return JS_FALSE; + return JS_EXCEPTION; } #ifdef ECMASCRIPT_DEBUG fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); diff --git a/src/ecmascript/quickjs/fragment.c b/src/ecmascript/quickjs/fragment.c index 6782cafa1..f72f12de8 100644 --- a/src/ecmascript/quickjs/fragment.c +++ b/src/ecmascript/quickjs/fragment.c @@ -1135,14 +1135,18 @@ js_fragment_contains(JSContext *ctx, JSValueConst this_val, int argc, JSValueCon dom_node *el = (dom_node *)(js_getopaque_fragment(this_val, js_fragment_class_id)); if (!el) { - return JS_FALSE; + return JS_EXCEPTION; } + dom_node *el2 = NULL; + + if (!JS_IsNull(argv[0])) { //dom_node_ref(el); - dom_node *el2 = (dom_node *)(js_getopaque_fragment(argv[0], js_fragment_class_id)); + el2 = (dom_node *)(js_getopaque_fragment(argv[0], js_fragment_class_id)); + } if (!el2) { //dom_node_unref(el); - return JS_FALSE; + return JS_EXCEPTION; } #ifdef ECMASCRIPT_DEBUG fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); diff --git a/src/ecmascript/quickjs/text.c b/src/ecmascript/quickjs/text.c index 4e5ed8722..708b1bfe2 100644 --- a/src/ecmascript/quickjs/text.c +++ b/src/ecmascript/quickjs/text.c @@ -1169,14 +1169,17 @@ js_text_contains(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst * dom_node *el = (dom_node *)(js_getopaque_text(this_val, js_text_class_id)); if (!el) { - return JS_FALSE; + return JS_EXCEPTION; } + dom_node *el2 = NULL; //dom_node_ref(el); - dom_node *el2 = (dom_node *)(js_getopaque_text(argv[0], js_text_class_id)); + if (!JS_IsNull(argv[0])) { + el2 = (dom_node *)(js_getopaque_text(argv[0], js_text_class_id)); + } if (!el2) { //dom_node_unref(el); - return JS_FALSE; + return JS_EXCEPTION; } #ifdef ECMASCRIPT_DEBUG fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);