1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[quickjs] getElement -> getNode

This commit is contained in:
Witold Filipczyk 2024-11-02 17:50:08 +01:00
parent c271046d76
commit 43f09a93d3
11 changed files with 110 additions and 68 deletions

View File

@ -22,6 +22,7 @@
#include "js/quickjs.h"
#include "js/quickjs/collection.h"
#include "js/quickjs/element.h"
#include "js/quickjs/node.h"
#define countof(x) (sizeof(x) / sizeof((x)[0]))
@ -162,7 +163,7 @@ js_htmlCollection_item2(JSContext *ctx, JSValueConst this_val, int idx)
dom_html_collection_unref(ns);
return JS_UNDEFINED;
}
ret = getElement(ctx, node);
ret = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -236,7 +237,7 @@ js_htmlCollection_namedItem2(JSContext *ctx, JSValueConst this_val, const char *
if (err == DOM_NO_ERR && val) {
if (dom_string_caseless_isequal(name, val)) {
JSValue ret = getElement(ctx, element);
JSValue ret = getNode(ctx, element);
dom_string_unref(val);
dom_string_unref(name);
#ifdef ECMASCRIPT_DEBUG
@ -253,7 +254,7 @@ js_htmlCollection_namedItem2(JSContext *ctx, JSValueConst this_val, const char *
if (err == DOM_NO_ERR && val) {
if (dom_string_caseless_isequal(name, val)) {
JSValue ret = getElement(ctx, element);
JSValue ret = getNode(ctx, element);
dom_string_unref(val);
dom_string_unref(name);
#ifdef ECMASCRIPT_DEBUG
@ -335,7 +336,7 @@ js_htmlCollection_set_items(JSContext *ctx, JSValue this_val, void *node)
if (err != DOM_NO_ERR || !element) {
continue;
}
JSValue obj = getElement(ctx, element);
JSValue obj = getNode(ctx, element);
REF_JS(obj);

View File

@ -22,6 +22,7 @@
#include "js/quickjs.h"
#include "js/quickjs/collection.h"
#include "js/quickjs/element.h"
#include "js/quickjs/node.h"
#define countof(x) (sizeof(x) / sizeof((x)[0]))
@ -118,7 +119,7 @@ js_htmlCollection2_item2(JSContext *ctx, JSValueConst this_val, int idx)
dom_html_collection_unref((dom_html_collection *)ns);
return JS_UNDEFINED;
}
ret = getElement(ctx, node);
ret = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -187,7 +188,7 @@ js_htmlCollection2_namedItem2(JSContext *ctx, JSValueConst this_val, const char
if (err == DOM_NO_ERR && val) {
if (dom_string_caseless_isequal(name, val)) {
JSValue ret = getElement(ctx, element);
JSValue ret = getNode(ctx, element);
dom_string_unref(val);
dom_string_unref(name);
#ifdef ECMASCRIPT_DEBUG
@ -204,7 +205,7 @@ js_htmlCollection2_namedItem2(JSContext *ctx, JSValueConst this_val, const char
if (err == DOM_NO_ERR && val) {
if (dom_string_caseless_isequal(name, val)) {
JSValue ret = getElement(ctx, element);
JSValue ret = getNode(ctx, element);
dom_string_unref(val);
dom_string_unref(name);
#ifdef ECMASCRIPT_DEBUG
@ -286,7 +287,7 @@ js_htmlCollection2_set_items(JSContext *ctx, JSValue this_val, void *node)
if (err != DOM_NO_ERR || !element) {
continue;
}
JSValue obj = getElement(ctx, element);
JSValue obj = getNode(ctx, element);
REF_JS(obj);
JS_SetPropertyUint32(ctx, this_val, counter, JS_DupValue(ctx, obj));

View File

@ -17,6 +17,7 @@
#include "js/quickjs.h"
#include "js/quickjs/element.h"
#include "js/quickjs/event.h"
#include "js/quickjs/node.h"
#include "intl/charsets.h"
#include "terminal/event.h"
#include "viewer/text/vs.h"
@ -204,7 +205,7 @@ js_customEvent_get_property_target(JSContext *ctx, JSValueConst this_val)
dom_event_unref(event);
return JS_NULL;
}
JSValue r = getElement(ctx, target);
JSValue r = getNode(ctx, target);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif

View File

@ -35,6 +35,7 @@
#include "js/quickjs/location.h"
#include "js/quickjs/document.h"
#include "js/quickjs/element.h"
#include "js/quickjs/node.h"
#include "js/quickjs/nodelist.h"
#include "js/quickjs/nodelist2.h"
#include "js/quickjs/text.h"
@ -193,7 +194,7 @@ js_document_get_property_body(JSContext *ctx, JSValueConst this_val)
return JS_NULL;
}
//dom_node_unref(doc);
JSValue rr = getElement(ctx, body);
JSValue rr = getNode(ctx, body);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -381,7 +382,7 @@ js_document_get_property_currentScript(JSContext *ctx, JSValueConst this_val)
dom_string_unref(tag_name);
if (isScript) {
return getElement(ctx, elem);
return getNode(ctx, elem);
}
}
}
@ -447,7 +448,7 @@ js_document_get_property_documentElement(JSContext *ctx, JSValueConst this_val)
return JS_NULL;
}
//dom_node_unref(doc);
JSValue rr = getElement(ctx, root);
JSValue rr = getNode(ctx, root);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -561,7 +562,7 @@ js_document_get_property_head(JSContext *ctx, JSValueConst this_val)
// TODO
return JS_NULL;
// return getElement(ctx, element);
// return getNode(ctx, element);
}
static JSValue
@ -1335,7 +1336,7 @@ js_document_createComment(JSContext *ctx, JSValueConst this_val, int argc, JSVal
}
//dom_node_unref(doc);
return getElement(ctx, comment);
return getNode(ctx, comment);
}
static JSValue
@ -1413,7 +1414,7 @@ js_document_createElement(JSContext *ctx, JSValueConst this_val, int argc, JSVal
return JS_NULL;
}
//dom_node_unref(doc);
JSValue rr = getElement(ctx, element);
JSValue rr = getNode(ctx, element);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1516,7 +1517,7 @@ js_document_getElementById(JSContext *ctx, JSValueConst this_val, int argc, JSVa
return JS_NULL;
}
//dom_node_unref(doc);
JSValue rr = getElement(ctx, element);
JSValue rr = getNode(ctx, element);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1704,7 +1705,7 @@ fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
}
//dom_node_unref(doc);
return getElement(ctx, ret);
return getNode(ctx, ret);
}
static JSValue

View File

@ -37,6 +37,7 @@
#include "js/quickjs/fragment.h"
#include "js/quickjs/heartbeat.h"
#include "js/quickjs/keyboard.h"
#include "js/quickjs/node.h"
#include "js/quickjs/nodelist.h"
#include "js/quickjs/nodelist2.h"
#include "js/quickjs/style.h"
@ -633,7 +634,7 @@ js_element_get_property_firstChild(JSContext *ctx, JSValueConst this_val)
//dom_node_unref(el);
return JS_NULL;
}
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -687,7 +688,7 @@ js_element_get_property_firstElementChild(JSContext *ctx, JSValueConst this_val)
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
dom_nodelist_unref(nodes);
JSValue rr = getElement(ctx, child);
JSValue rr = getNode(ctx, child);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -829,7 +830,7 @@ js_element_get_property_lastChild(JSContext *ctx, JSValueConst this_val)
//dom_node_unref(el);
return JS_NULL;
}
JSValue rr = getElement(ctx, last_child);
JSValue rr = getNode(ctx, last_child);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -882,7 +883,7 @@ js_element_get_property_lastElementChild(JSContext *ctx, JSValueConst this_val)
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
dom_nodelist_unref(nodes);
JSValue rr = getElement(ctx, child);
JSValue rr = getNode(ctx, child);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -936,7 +937,7 @@ fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
exc = dom_node_get_node_type(next, &type);
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
JSValue rr = getElement(ctx, next);
JSValue rr = getNode(ctx, next);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1100,7 +1101,7 @@ js_element_get_property_nextSibling(JSContext *ctx, JSValueConst this_val)
return JS_NULL;
}
//dom_node_unref(el);
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1203,7 +1204,7 @@ js_element_get_property_offsetParent(JSContext *ctx, JSValueConst this_val)
}
//dom_node_unref(el);
return getElement(ctx, node);
return getNode(ctx, node);
}
#if 0
@ -1313,7 +1314,7 @@ js_element_get_property_parentElement(JSContext *ctx, JSValueConst this_val)
//dom_node_unref(el);
return JS_NULL;
}
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1343,7 +1344,7 @@ js_element_get_property_parentNode(JSContext *ctx, JSValueConst this_val)
//dom_node_unref(el);
return JS_NULL;
}
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1388,7 +1389,7 @@ fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
exc = dom_node_get_node_type(prev, &type);
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
JSValue rr = getElement(ctx, prev);
JSValue rr = getNode(ctx, prev);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1425,7 +1426,7 @@ js_element_get_property_previousSibling(JSContext *ctx, JSValueConst this_val)
return JS_NULL;
}
//dom_node_unref(el);
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -2636,7 +2637,7 @@ js_element_appendChild(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
if (exc == DOM_NO_ERR && res) {
interpreter->changed = 1;
//dom_node_unref(el);
JSValue rr = getElement(ctx, res);
JSValue rr = getNode(ctx, res);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -2749,7 +2750,7 @@ js_element_cloneNode(JSContext *ctx, JSValueConst this_val, int argc, JSValueCon
return JS_NULL;
}
//dom_node_unref(el);
JSValue rr = getElement(ctx, clone);
JSValue rr = getNode(ctx, clone);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -2872,7 +2873,7 @@ fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
if (!res) {
return JS_NULL;
}
JSValue ret = getElement(ctx, res);
JSValue ret = getNode(ctx, res);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -3328,7 +3329,7 @@ js_element_insertBefore(JSContext *ctx, JSValueConst this_val, int argc, JSValue
interpreter->changed = 1;
//dom_node_unref(el);
JSValue rr = getElement(ctx, spare);
JSValue rr = getNode(ctx, spare);
dom_node_unref(spare);
return rr;
@ -3485,7 +3486,7 @@ js_element_querySelector(JSContext *ctx, JSValueConst this_val, int argc, JSValu
return JS_NULL;
}
//dom_node_unref(el);
JSValue rr = getElement(ctx, ret);
JSValue rr = getNode(ctx, ret);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -3656,7 +3657,7 @@ js_element_removeChild(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
interpreter->changed = 1;
//dom_node_unref(el);
return getElement(ctx, spare);
return getNode(ctx, spare);
}
//dom_node_unref(el);

View File

@ -15,6 +15,7 @@
#include "js/quickjs.h"
#include "js/quickjs/element.h"
#include "js/quickjs/event.h"
#include "js/quickjs/node.h"
#include "intl/charsets.h"
#include "terminal/event.h"
@ -164,7 +165,7 @@ js_event_get_property_target(JSContext *ctx, JSValueConst this_val)
if (exc != DOM_NO_ERR || !target) {
return JS_NULL;
}
JSValue r = getElement(ctx, target);
JSValue r = getNode(ctx, target);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif

View File

@ -36,6 +36,7 @@
#include "js/quickjs/fragment.h"
#include "js/quickjs/heartbeat.h"
#include "js/quickjs/keyboard.h"
#include "js/quickjs/node.h"
#include "js/quickjs/nodelist.h"
#include "js/quickjs/nodelist2.h"
#include "js/quickjs/style.h"
@ -205,7 +206,7 @@ js_fragment_get_property_firstChild(JSContext *ctx, JSValueConst this_val)
//dom_node_unref(el);
return JS_NULL;
}
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -259,7 +260,7 @@ js_fragment_get_property_firstElementChild(JSContext *ctx, JSValueConst this_val
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
dom_nodelist_unref(nodes);
JSValue rr = getElement(ctx, child);
JSValue rr = getNode(ctx, child);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -300,7 +301,7 @@ js_fragment_get_property_lastChild(JSContext *ctx, JSValueConst this_val)
//dom_node_unref(el);
return JS_NULL;
}
JSValue rr = getElement(ctx, last_child);
JSValue rr = getNode(ctx, last_child);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -353,7 +354,7 @@ js_fragment_get_property_lastElementChild(JSContext *ctx, JSValueConst this_val)
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
dom_nodelist_unref(nodes);
JSValue rr = getElement(ctx, child);
JSValue rr = getNode(ctx, child);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -408,7 +409,7 @@ fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
exc = dom_node_get_node_type(next, &type);
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
JSValue rr = getElement(ctx, next);
JSValue rr = getNode(ctx, next);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -573,7 +574,7 @@ js_fragment_get_property_nextSibling(JSContext *ctx, JSValueConst this_val)
return JS_NULL;
}
//dom_node_unref(el);
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -620,7 +621,7 @@ js_fragment_get_property_parentElement(JSContext *ctx, JSValueConst this_val)
//dom_node_unref(el);
return JS_NULL;
}
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -650,7 +651,7 @@ js_fragment_get_property_parentNode(JSContext *ctx, JSValueConst this_val)
//dom_node_unref(el);
return JS_NULL;
}
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -696,7 +697,7 @@ fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
exc = dom_node_get_node_type(prev, &type);
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
JSValue rr = getElement(ctx, prev);
JSValue rr = getNode(ctx, prev);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -734,7 +735,7 @@ js_fragment_get_property_previousSibling(JSContext *ctx, JSValueConst this_val)
return JS_NULL;
}
//dom_node_unref(el);
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1073,7 +1074,7 @@ js_fragment_appendChild(JSContext *ctx, JSValueConst this_val, int argc, JSValue
if (exc == DOM_NO_ERR && res) {
interpreter->changed = 1;
//dom_node_unref(el);
JSValue rr = getElement(ctx, res);
JSValue rr = getNode(ctx, res);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1117,7 +1118,7 @@ js_fragment_cloneNode(JSContext *ctx, JSValueConst this_val, int argc, JSValueCo
return JS_NULL;
}
//dom_node_unref(el);
JSValue rr = getElement(ctx, clone);
JSValue rr = getNode(ctx, clone);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1299,7 +1300,7 @@ js_fragment_insertBefore(JSContext *ctx, JSValueConst this_val, int argc, JSValu
interpreter->changed = 1;
//dom_node_unref(el);
JSValue rr = getElement(ctx, spare);
JSValue rr = getNode(ctx, spare);
dom_node_unref(spare);
return rr;
@ -1426,7 +1427,7 @@ js_fragment_querySelector(JSContext *ctx, JSValueConst this_val, int argc, JSVal
return JS_NULL;
}
//dom_node_unref(el);
JSValue rr = getElement(ctx, ret);
JSValue rr = getNode(ctx, ret);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1521,7 +1522,7 @@ js_fragment_removeChild(JSContext *ctx, JSValueConst this_val, int argc, JSValue
interpreter->changed = 1;
//dom_node_unref(el);
return getElement(ctx, spare);
return getNode(ctx, spare);
}
//dom_node_unref(el);

View File

@ -18,6 +18,7 @@
#include "js/quickjs.h"
#include "js/quickjs/element.h"
#include "js/quickjs/keyboard.h"
#include "js/quickjs/node.h"
#include "intl/charsets.h"
#include "terminal/event.h"
@ -255,7 +256,7 @@ js_keyboardEvent_get_property_target(JSContext *ctx, JSValueConst this_val)
dom_event_unref(event);
return JS_NULL;
}
JSValue r = getElement(ctx, target);
JSValue r = getNode(ctx, target);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif

View File

@ -19,6 +19,7 @@
#include "js/quickjs/mapa.h"
#include "js/quickjs.h"
#include "js/quickjs/element.h"
#include "js/quickjs/node.h"
#include "js/quickjs/nodelist.h"
@ -136,7 +137,7 @@ js_nodeList_item2(JSContext *ctx, JSValueConst this_val, int idx)
dom_nodelist_unref(nl);
return JS_UNDEFINED;
}
ret = getElement(ctx, element);
ret = getNode(ctx, element);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -196,7 +197,7 @@ js_nodeList_set_items(JSContext *ctx, JSValue this_val, void *node)
continue;
}
obj = getElement(ctx, element);
obj = getNode(ctx, element);
REF_JS(obj);
JS_SetPropertyUint32(ctx, this_val, i, JS_DupValue(ctx, obj));

View File

@ -26,6 +26,7 @@
#include "js/quickjs/mapa.h"
#include "js/quickjs.h"
#include "js/quickjs/element.h"
#include "js/quickjs/node.h"
#include "js/quickjs/nodelist2.h"
#include "js/quickjs/window.h"
#include "intl/libintl.h"
@ -136,7 +137,7 @@ getNodeList2(JSContext *ctx, void *nodes)
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
dom_node_ref((dom_node *)(sn->node));
JSValue obj = getElement(ctx, sn->node);
JSValue obj = getNode(ctx, sn->node);
REF_JS(obj);
JS_SetPropertyUint32(ctx, proto, i, JS_DupValue(ctx, obj));

View File

@ -35,6 +35,7 @@
#include "js/quickjs/event.h"
#include "js/quickjs/heartbeat.h"
#include "js/quickjs/keyboard.h"
#include "js/quickjs/node.h"
#include "js/quickjs/nodelist.h"
#include "js/quickjs/nodelist2.h"
#include "js/quickjs/style.h"
@ -205,7 +206,7 @@ js_text_get_property_firstChild(JSContext *ctx, JSValueConst this_val)
//dom_node_unref(el);
return JS_NULL;
}
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -259,7 +260,7 @@ js_text_get_property_firstElementChild(JSContext *ctx, JSValueConst this_val)
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
dom_nodelist_unref(nodes);
JSValue rr = getElement(ctx, child);
JSValue rr = getNode(ctx, child);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -300,7 +301,7 @@ js_text_get_property_lastChild(JSContext *ctx, JSValueConst this_val)
//dom_node_unref(el);
return JS_NULL;
}
JSValue rr = getElement(ctx, last_child);
JSValue rr = getNode(ctx, last_child);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -353,7 +354,7 @@ js_text_get_property_lastElementChild(JSContext *ctx, JSValueConst this_val)
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
dom_nodelist_unref(nodes);
JSValue rr = getElement(ctx, child);
JSValue rr = getNode(ctx, child);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -408,7 +409,7 @@ fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
exc = dom_node_get_node_type(next, &type);
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
JSValue rr = getElement(ctx, next);
JSValue rr = getNode(ctx, next);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -572,7 +573,7 @@ js_text_get_property_nextSibling(JSContext *ctx, JSValueConst this_val)
return JS_NULL;
}
//dom_node_unref(el);
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -619,7 +620,7 @@ js_text_get_property_parentElement(JSContext *ctx, JSValueConst this_val)
//dom_node_unref(el);
return JS_NULL;
}
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -649,7 +650,7 @@ js_text_get_property_parentNode(JSContext *ctx, JSValueConst this_val)
//dom_node_unref(el);
return JS_NULL;
}
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -695,7 +696,7 @@ fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
exc = dom_node_get_node_type(prev, &type);
if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) {
JSValue rr = getElement(ctx, prev);
JSValue rr = getNode(ctx, prev);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -733,7 +734,7 @@ js_text_get_property_previousSibling(JSContext *ctx, JSValueConst this_val)
return JS_NULL;
}
//dom_node_unref(el);
JSValue rr = getElement(ctx, node);
JSValue rr = getNode(ctx, node);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -742,6 +743,36 @@ fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
return rr;
}
static JSValue
js_text_get_property_tagName(JSContext *ctx, JSValueConst this_val)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
REF_JS(this_val);
JSValue r;
dom_node *el = (dom_node *)(js_getopaque_text(this_val, js_text_class_id));
if (!el) {
return JS_NULL;
}
//dom_node_ref(el);
dom_string *tag_name = NULL;
dom_exception exc = dom_node_get_node_name(el, &tag_name);
if (exc != DOM_NO_ERR || !tag_name) {
//dom_node_unref(el);
return JS_NULL;
}
r = JS_NewStringLen(ctx, dom_string_data(tag_name), dom_string_length(tag_name));
dom_string_unref(tag_name);
//dom_node_unref(el);
RETURN_JS(r);
}
static JSValue
js_text_get_property_textContent(JSContext *ctx, JSValueConst this_val)
{
@ -1070,7 +1101,7 @@ js_text_appendChild(JSContext *ctx, JSValueConst this_val, int argc, JSValueCons
if (exc == DOM_NO_ERR && res) {
interpreter->changed = 1;
//dom_node_unref(el);
JSValue rr = getElement(ctx, res);
JSValue rr = getNode(ctx, res);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1114,7 +1145,7 @@ js_text_cloneNode(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst
return JS_NULL;
}
//dom_node_unref(el);
JSValue rr = getElement(ctx, clone);
JSValue rr = getNode(ctx, clone);
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
#endif
@ -1295,7 +1326,7 @@ js_text_insertBefore(JSContext *ctx, JSValueConst this_val, int argc, JSValueCon
interpreter->changed = 1;
//dom_node_unref(el);
JSValue rr = getElement(ctx, spare);
JSValue rr = getNode(ctx, spare);
dom_node_unref(spare);
return rr;
@ -1418,7 +1449,7 @@ js_text_removeChild(JSContext *ctx, JSValueConst this_val, int argc, JSValueCons
interpreter->changed = 1;
//dom_node_unref(el);
return getElement(ctx, spare);
return getNode(ctx, spare);
}
//dom_node_unref(el);
@ -1454,6 +1485,7 @@ static const JSCFunctionListEntry js_text_proto_funcs[] = {
JS_CGETSET_DEF("parentNode", js_text_get_property_parentNode, NULL), // Node
//// JS_CGETSET_DEF("previousElementSibling", js_text_get_property_previousElementSibling, NULL),
JS_CGETSET_DEF("previousSibling", js_text_get_property_previousSibling, NULL), // Node
JS_CGETSET_DEF("tagName", js_text_get_property_tagName, NULL), // Node
JS_CGETSET_DEF("textContent", js_text_get_property_textContent, js_text_set_property_textContent), // Node
JS_CFUNC_DEF("addEventListener", 3, js_text_addEventListener),