mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 08:51:22 +00:00
Fix broken call node removal in normalize
removeChild is the correct api Fixes #145
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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>';
|
||||
|
||||
Reference in New Issue
Block a user