Fix broken call node removal in normalize

removeChild is the correct api
Fixes #145
This commit is contained in:
Daniel Freedman
2015-01-20 11:45:04 -08:00
parent 21dc1a2e29
commit 3ceb98fadf
2 changed files with 20 additions and 1 deletions

View File

@@ -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 {

View File

@@ -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 = '<b></b>';