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

Commit 2c273a1

Browse files
committed
Merge pull request #396 from arv/element-remove
Implement ChildNode remove
2 parents 4c2f646 + fe9e019 commit 2c273a1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/wrappers/node-interfaces.js

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
}
5151
wrapperList.length = i;
5252
return wrapperList;
53+
},
54+
55+
remove() {
56+
var p = this.parentNode;
57+
if (p)
58+
p.removeChild(this);
5359
}
5460
};
5561

test/js/ChildNodeInterface.js

+12
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,16 @@ suite('ChildNodeInterface', function() {
5151
assert.equal(tree.j.previousElementSibling, tree.content);
5252
});
5353

54+
test('remove', function() {
55+
var div = document.createElement('div');
56+
div.innerHTML = '<a></a>';
57+
var a = div.firstChild;
58+
a.remove();
59+
assert.equal(div.firstChild, null);
60+
assert.equal(a.parentNode, null);
61+
62+
// no op.
63+
div.remove();
64+
});
65+
5466
});

0 commit comments

Comments
 (0)