1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

[mujs] DocumentFragment.nodeValue and Element.nodeValue setters

This commit is contained in:
Witold Filipczyk 2024-09-18 15:34:49 +02:00
parent b1e881de3c
commit 53a06709eb
2 changed files with 64 additions and 2 deletions

View File

@ -903,6 +903,37 @@ mjs_element_get_property_nodeValue(js_State *J)
dom_string_unref(content);
}
static void
mjs_element_set_property_nodeValue(js_State *J)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
dom_node *node = (dom_node *)(mjs_getprivate(J, 0));
if (!node) {
js_error(J, "error");
return;
}
const char *str = js_tostring(J, 1);
if (!str) {
js_error(J, "out of memory");
return;
}
dom_string *value = NULL;
dom_exception exc = dom_string_create((const uint8_t *)str, strlen(str), &value);
if (exc != DOM_NO_ERR || !value) {
js_pushundefined(J);
return;
}
exc = dom_node_set_node_value(node, value);
dom_string_unref(value);
js_pushundefined(J);
}
static void
mjs_element_get_property_nextSibling(js_State *J)
{
@ -3402,7 +3433,7 @@ fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
addproperty(J, "nextSibling", mjs_element_get_property_nextSibling, NULL);
addproperty(J, "nodeName", mjs_element_get_property_nodeName, NULL);
addproperty(J, "nodeType", mjs_element_get_property_nodeType, NULL);
addproperty(J, "nodeValue", mjs_element_get_property_nodeValue, NULL);
addproperty(J, "nodeValue", mjs_element_get_property_nodeValue, mjs_element_set_property_nodeValue);
// addproperty(J, "offsetHeight", mjs_element_get_property_offsetHeight, NULL);
// addproperty(J, "offsetLeft", mjs_element_get_property_offsetLeft, NULL);
addproperty(J, "offsetParent", mjs_element_get_property_offsetParent, NULL);

View File

@ -464,6 +464,37 @@ mjs_fragment_get_property_nodeValue(js_State *J)
dom_string_unref(content);
}
static void
mjs_fragment_set_property_nodeValue(js_State *J)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
dom_node *node = (dom_node *)(mjs_getprivate_fragment(J, 0));
if (!node) {
js_error(J, "error");
return;
}
const char *str = js_tostring(J, 1);
if (!str) {
js_error(J, "out of memory");
return;
}
dom_string *value = NULL;
dom_exception exc = dom_string_create((const uint8_t *)str, strlen(str), &value);
if (exc != DOM_NO_ERR || !value) {
js_pushundefined(J);
return;
}
exc = dom_node_set_node_value(node, value);
dom_string_unref(value);
js_pushundefined(J);
}
static void
mjs_fragment_get_property_nextSibling(js_State *J)
{
@ -1306,7 +1337,7 @@ fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__);
addproperty(J, "nextSibling", mjs_fragment_get_property_nextSibling, NULL);
addproperty(J, "nodeName", mjs_fragment_get_property_nodeName, NULL);
addproperty(J, "nodeType", mjs_fragment_get_property_nodeType, NULL);
addproperty(J, "nodeValue", mjs_fragment_get_property_nodeValue, NULL);
addproperty(J, "nodeValue", mjs_fragment_get_property_nodeValue, mjs_fragment_set_property_nodeValue);
addproperty(J, "ownerDocument", mjs_fragment_get_property_ownerDocument, NULL);
addproperty(J, "parentElement", mjs_fragment_get_property_parentElement, NULL);
addproperty(J, "parentNode", mjs_fragment_get_property_parentNode, NULL);