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

Commit

Permalink
Implement ChildNode remove
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Mar 10, 2014
1 parent 4c2f646 commit fe9e019
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/wrappers/node-interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
}
wrapperList.length = i;
return wrapperList;
},

remove() {
var p = this.parentNode;
if (p)
p.removeChild(this);
}
};

Expand Down
12 changes: 12 additions & 0 deletions test/js/ChildNodeInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,16 @@ suite('ChildNodeInterface', function() {
assert.equal(tree.j.previousElementSibling, tree.content);
});

test('remove', function() {
var div = document.createElement('div');
div.innerHTML = '<a></a>';
var a = div.firstChild;
a.remove();
assert.equal(div.firstChild, null);
assert.equal(a.parentNode, null);

// no op.
div.remove();
});

});

0 comments on commit fe9e019

Please sign in to comment.