summaryrefslogtreecommitdiff
path: root/content/handlers/javascript
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2019-05-04 17:57:45 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2019-05-04 17:57:45 +0100
commit85a4792280290e7a2ce12ec200032dee1848ad12 (patch)
tree3c3c1689b57026a502d9b7072aae257d95b7e2eb /content/handlers/javascript
parented829a477222f169e4ff0727db920e8029fd0c7d (diff)
downloadnetsurf-85a4792280290e7a2ce12ec200032dee1848ad12.tar.gz
netsurf-85a4792280290e7a2ce12ec200032dee1848ad12.tar.bz2
Add createElementNS
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'content/handlers/javascript')
-rw-r--r--content/handlers/javascript/duktape/Document.bnd40
-rw-r--r--content/handlers/javascript/duktape/dukky.c3
2 files changed, 42 insertions, 1 deletions
diff --git a/content/handlers/javascript/duktape/Document.bnd b/content/handlers/javascript/duktape/Document.bnd
index 23e0425e2..8901115d6 100644
--- a/content/handlers/javascript/duktape/Document.bnd
+++ b/content/handlers/javascript/duktape/Document.bnd
@@ -147,6 +147,46 @@ method Document::createElement()
return 1;
%}
+method Document::createElementNS()
+%{
+ dom_node *newnode;
+ dom_exception err;
+ duk_size_t text_len;
+ duk_size_t ns_len;
+ const char *ns = duk_safe_to_lstring(ctx, 0, &ns_len);
+ const char *text = duk_safe_to_lstring(ctx, 0, &text_len);
+ dom_string *text_str;
+ dom_string *ns_str;
+
+ err = dom_string_create((const uint8_t*)ns, ns_len, &ns_str);
+ if (err != DOM_NO_ERR) return 0; /* coerced to undefined */
+
+ err = dom_string_create((const uint8_t*)text, text_len, &text_str);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(ns_str);
+ return 0; /* coerced to undefined */
+ }
+
+ err = dom_document_create_element_ns(priv->parent.node,
+ ns_str,
+ text_str,
+ &newnode);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(ns_str);
+ dom_string_unref(text_str);
+ return 0; /* coerced to undefined */
+ }
+
+ dom_string_unref(text_str);
+ dom_string_unref(ns_str);
+
+ dukky_push_node(ctx, newnode);
+
+ dom_node_unref(newnode);
+
+ return 1;
+%}
+
getter Document::head()
%{
struct dom_nodelist *nodes;
diff --git a/content/handlers/javascript/duktape/dukky.c b/content/handlers/javascript/duktape/dukky.c
index 171736338..8fa011ebc 100644
--- a/content/handlers/javascript/duktape/dukky.c
+++ b/content/handlers/javascript/duktape/dukky.c
@@ -721,7 +721,8 @@ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen, const char *name)
assert(ctx);
if (txt == NULL || txtlen == 0) return false;
duk_set_top(CTX, 0);
- NSLOG(dukky, DEEPDEBUG, "%zd bytes: %s", txtlen, txt);
+ NSLOG(dukky, DEEPDEBUG, "Running %zd bytes from %s", txtlen, name);
+ NSLOG(dukky, DEEPDEBUG, "\n%s\n", txt);
(void) nsu_getmonotonic_ms(&ctx->exec_start_time);
if (name != NULL) {