diff --git a/src/ShadowDOM/wrappers/Node.js b/src/ShadowDOM/wrappers/Node.js index d174de6..c670e91 100644 --- a/src/ShadowDOM/wrappers/Node.js +++ b/src/ShadowDOM/wrappers/Node.js @@ -692,7 +692,7 @@ n = nodes[i]; if (n.nodeType === Node.TEXT_NODE) { if (!modNode && !n.data.length) - this.removeNode(n); + this.removeChild(n); else if (!modNode) modNode = n; else { diff --git a/tests/ShadowDOM/js/Node.js b/tests/ShadowDOM/js/Node.js index a0b9dbe..3fbd142 100644 --- a/tests/ShadowDOM/js/Node.js +++ b/tests/ShadowDOM/js/Node.js @@ -416,6 +416,25 @@ suite('Node', function() { assert.equal(div.childNodes.length, 3); }); + test('normalize - issue 145', function() { + var div = document.createElement('div'); + div.appendChild(document.createTextNode('')); + div.appendChild(document.createTextNode('')); + div.appendChild(document.createTextNode('')); + var childDiv = document.createElement('div'); + childDiv.appendChild(document.createTextNode('')); + childDiv.appendChild(document.createTextNode('')); + div.appendChild(childDiv); + + assert.equal(div.childNodes.length, 4); + assert.equal(childDiv.childNodes.length, 2); + + div.normalize(); + + assert.equal(div.childNodes.length, 1); + assert.equal(childDiv.childNodes.length, 0); + }); + test('appendChild last and first', function() { var a = document.createElement('a'); a.innerHTML = '';