summaryrefslogtreecommitdiff
path: root/javascript/duktape/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/duktape/node.c')
-rw-r--r--javascript/duktape/node.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/javascript/duktape/node.c b/javascript/duktape/node.c
index d632a2414..2d7b1cf29 100644
--- a/javascript/duktape/node.c
+++ b/javascript/duktape/node.c
@@ -56,10 +56,31 @@ static DUKKY_FUNC(node, appendChild)
return 0;
}
+static DUKKY_GETTER(node, textContent)
+{
+ DUKKY_GET_METHOD_PRIVATE(node);
+ dom_exception exc;
+ dom_string *content;
+
+ exc = dom_node_get_text_content(priv->node, &content);
+ if (exc != DOM_NO_ERR) {
+ return 0;
+ }
+
+ if (content != NULL) {
+ duk_push_lstring(ctx, dom_string_data(content), dom_string_length(content));
+ dom_string_unref(content);
+ return 1;
+ }
+
+ return 0;
+}
+
DUKKY_FUNC(node, __proto)
{
/* Populate node's prototypical functionality */
DUKKY_ADD_METHOD(node, appendChild, 1);
+ DUKKY_POPULATE_READONLY_PROPERTY(node, textContent);
/* Set this prototype's prototype (left-parent)*/
DUKKY_GET_PROTOTYPE(event_target);
duk_set_prototype(ctx, 0);