diff --git a/src/ecmascript/quickjs/element.c b/src/ecmascript/quickjs/element.c index eedc524a8..92e075b66 100644 --- a/src/ecmascript/quickjs/element.c +++ b/src/ecmascript/quickjs/element.c @@ -2613,14 +2613,18 @@ js_element_appendChild(JSContext *ctx, JSValueConst this_val, int argc, JSValueC dom_exception exc; if (argc != 1) { - return JS_NULL; + return JS_EXCEPTION; } if (!el) { return JS_EXCEPTION; } //dom_node_ref(el); - dom_node *el2 = (dom_node *)js_getopaque_any(argv[0]); + dom_node *el2 = NULL; + + if (!JS_IsNull(argv[0])) { + el2 = (dom_node *)js_getopaque_any(argv[0]); + } if (!el2) { //dom_node_unref(el); diff --git a/src/ecmascript/quickjs/fragment.c b/src/ecmascript/quickjs/fragment.c index 06e10e6c4..6782cafa1 100644 --- a/src/ecmascript/quickjs/fragment.c +++ b/src/ecmascript/quickjs/fragment.c @@ -1014,14 +1014,18 @@ js_fragment_appendChild(JSContext *ctx, JSValueConst this_val, int argc, JSValue dom_exception exc; if (argc != 1) { - return JS_NULL; + return JS_EXCEPTION; } if (!el) { return JS_EXCEPTION; } //dom_node_ref(el); - dom_node *el2 = (dom_node *)(js_getopaque_fragment(argv[0], js_fragment_class_id)); + dom_node *el2 = NULL; + + if (!JS_IsNull(argv[0])) { + el2 = (dom_node *)(js_getopaque_fragment(argv[0], js_fragment_class_id)); + } if (!el2) { //dom_node_unref(el); diff --git a/src/ecmascript/quickjs/text.c b/src/ecmascript/quickjs/text.c index 7211ddfee..4e5ed8722 100644 --- a/src/ecmascript/quickjs/text.c +++ b/src/ecmascript/quickjs/text.c @@ -1048,14 +1048,18 @@ js_text_appendChild(JSContext *ctx, JSValueConst this_val, int argc, JSValueCons dom_exception exc; if (argc != 1) { - return JS_NULL; + return JS_EXCEPTION; } if (!el) { return JS_EXCEPTION; } //dom_node_ref(el); - dom_node *el2 = (dom_node *)(js_getopaque_text(argv[0], js_text_class_id)); + dom_node *el2 = NULL; + + if (!JS_IsNull(argv[0])) { + el2 = (dom_node *)(js_getopaque_text(argv[0], js_text_class_id)); + } if (!el2) { //dom_node_unref(el);