Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Inverted hasChildNodes() logic to ensure that the existance of a firs…
Browse files Browse the repository at this point in the history
…tChild means there are childNodes. Added test to verify hasChildNodes() change with formatting per guidelines.
  • Loading branch information
labriola committed Oct 9, 2013
1 parent 0f72cea commit 895860f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/wrappers/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
},

hasChildNodes: function() {
return this.firstChild === null;
return this.firstChild !== null;
},

/** @type {Node} */
Expand Down
12 changes: 12 additions & 0 deletions test/js/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,16 @@ suite('Node', function() {

expectStructure(host2, {});
});

test('hasChildNodes without a shadow root', function() {
var div = document.createElement('div');

assert.isFalse(div.hasChildNodes(), 'should be false with no children');

div.innerHTML = '<span></span>';
assert.isTrue(div.hasChildNodes(), 'should be true with a single child');

div.innerHTML = '<span></span><ul></ul>';
assert.isTrue(div.hasChildNodes(), 'should be true with multiple children');
});
});

0 comments on commit 895860f

Please sign in to comment.