Correct some incorrect error case handling and add tests to demonstrate fix
This commit is contained in:
parent
2f52338328
commit
c752c85618
|
@ -73,7 +73,6 @@ getter Node::parentNode()
|
|||
dom_node *pnode = NULL;
|
||||
exc = dom_node_get_parent_node(priv->node, &pnode);
|
||||
if (exc != DOM_NO_ERR) return 0;
|
||||
if (pnode == NULL) return 0;
|
||||
dukky_push_node(ctx, pnode);
|
||||
dom_node_unref(pnode);
|
||||
return 1;
|
||||
|
@ -83,15 +82,16 @@ getter Node::parentElement()
|
|||
%{
|
||||
dom_exception exc;
|
||||
dom_node *pnode = NULL;
|
||||
dom_node_type ntype;
|
||||
dom_node_type ntype = DOM_NODE_TYPE_COUNT + 1;
|
||||
exc = dom_node_get_parent_node(priv->node, &pnode);
|
||||
if (exc != DOM_NO_ERR) return 0;
|
||||
if (pnode == NULL) return 0;
|
||||
exc = dom_node_get_node_type(pnode, &ntype);
|
||||
if (exc != DOM_NO_ERR) { dom_node_unref(pnode); return 0; }
|
||||
dukky_push_node(ctx, pnode);
|
||||
if (pnode != NULL) {
|
||||
exc = dom_node_get_node_type(pnode, &ntype);
|
||||
if (exc != DOM_NO_ERR) { dom_node_unref(pnode); return 0; }
|
||||
}
|
||||
dukky_push_node(ctx, (ntype == DOM_ELEMENT_NODE) ? pnode : NULL);
|
||||
dom_node_unref(pnode);
|
||||
return (ntype == DOM_ELEMENT_NODE) ? 1 : 0;
|
||||
return 1;
|
||||
%}
|
||||
|
||||
method Node::hasChildNodes()
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>DOM Node::nodeType</title></head>
|
||||
<body>
|
||||
<h1>Node::ParentNode</h1>
|
||||
<h2>These should all resolve to nodes of some kind.</h2>
|
||||
<script>
|
||||
document.write("<p>document is: ",
|
||||
document, "</p>");
|
||||
document.write("<p>document.body is: ",
|
||||
document.body, "</p>");
|
||||
document.write("<p>document.body.parentNode: ",
|
||||
document.body.parentNode, "</p>");
|
||||
</script>
|
||||
<h2>These should all resolve to null.</h2>
|
||||
<script>
|
||||
document.write("<p>document.parentNode is: ",
|
||||
document.parentNode, "</p>");
|
||||
document.write("<p>document.createElement('foo').parentNode is: ",
|
||||
document.createElement('foo').parentNode, "</p>");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -66,6 +66,7 @@
|
|||
<h3>DOM node tests</h3>
|
||||
<ul>
|
||||
<li><a href="dom-node-nodetype.html">Node::nodeType support</a></li>
|
||||
<li><a href="dom-node-parentNode.html">Node::parentNode support</a></li>
|
||||
</ul>
|
||||
|
||||
<h3>Document element specific</h3>
|
||||
|
|
Loading…
Reference in New Issue