From 895860f8f442d4ae68df320e84b74a9e8347df2b Mon Sep 17 00:00:00 2001 From: labriola Date: Wed, 9 Oct 2013 10:04:51 -0500 Subject: [PATCH] Inverted hasChildNodes() logic to ensure that the existance of a firstChild means there are childNodes. Added test to verify hasChildNodes() change with formatting per guidelines. --- src/wrappers/Node.js | 2 +- test/js/Node.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/wrappers/Node.js b/src/wrappers/Node.js index 9633c59..1aa4819 100644 --- a/src/wrappers/Node.js +++ b/src/wrappers/Node.js @@ -373,7 +373,7 @@ }, hasChildNodes: function() { - return this.firstChild === null; + return this.firstChild !== null; }, /** @type {Node} */ diff --git a/test/js/Node.js b/test/js/Node.js index cd7a5d3..95cdfc6 100644 --- a/test/js/Node.js +++ b/test/js/Node.js @@ -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 = ''; + assert.isTrue(div.hasChildNodes(), 'should be true with a single child'); + + div.innerHTML = ''; + assert.isTrue(div.hasChildNodes(), 'should be true with multiple children'); + }); });