From 0645bc7570974531be344544b68a7e93908d1796 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 20 Oct 2015 22:49:41 +0100 Subject: The node acessors should return javacript null not an error --- javascript/duktape/Node.bnd | 48 ++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'javascript') diff --git a/javascript/duktape/Node.bnd b/javascript/duktape/Node.bnd index 3a723ddfb..87d7e9292 100644 --- a/javascript/duktape/Node.bnd +++ b/javascript/duktape/Node.bnd @@ -132,14 +132,18 @@ getter Node::firstChild() dom_exception exc; dom_node *n; exc = dom_node_get_first_child(priv->node, &n); - if ((exc != DOM_NO_ERR) || (n == NULL)) { + if (exc != DOM_NO_ERR) { return 0; } - if (dukky_push_node(ctx, n) == false) { + if (n == NULL) { + duk_push_null(ctx); + } else { + if (dukky_push_node(ctx, n) == false) { + dom_node_unref(n); + return 0; + } dom_node_unref(n); - return 0; } - dom_node_unref(n); return 1; %} @@ -148,14 +152,18 @@ getter Node::lastChild() dom_exception exc; dom_node *n; exc = dom_node_get_last_child(priv->node, &n); - if ((exc != DOM_NO_ERR) || (n == NULL)) { + if (exc != DOM_NO_ERR) { return 0; } - if (dukky_push_node(ctx, n) == false) { + if (n == NULL) { + duk_push_null(ctx); + } else { + if (dukky_push_node(ctx, n) == false) { + dom_node_unref(n); + return 0; + } dom_node_unref(n); - return 0; } - dom_node_unref(n); return 1; %} @@ -164,14 +172,18 @@ getter Node::previousSibling() dom_exception exc; dom_node *n; exc = dom_node_get_previous_sibling(priv->node, &n); - if ((exc != DOM_NO_ERR) || (n == NULL)) { + if (exc != DOM_NO_ERR) { return 0; } - if (dukky_push_node(ctx, n) == false) { + if (n == NULL) { + duk_push_null(ctx); + } else { + if (dukky_push_node(ctx, n) == false) { + dom_node_unref(n); + return 0; + } dom_node_unref(n); - return 0; } - dom_node_unref(n); return 1; %} @@ -180,14 +192,18 @@ getter Node::nextSibling() dom_exception exc; dom_node *n; exc = dom_node_get_next_sibling(priv->node, &n); - if ((exc != DOM_NO_ERR) || (n == NULL)) { + if (exc != DOM_NO_ERR) { return 0; } - if (dukky_push_node(ctx, n) == false) { + if (n == NULL) { + duk_push_null(ctx); + } else { + if (dukky_push_node(ctx, n) == false) { + dom_node_unref(n); + return 0; + } dom_node_unref(n); - return 0; } - dom_node_unref(n); return 1; %} -- cgit v1.2.3