Skip to content

Commit

Permalink
make .empty just clear the .innerHTML
Browse files Browse the repository at this point in the history
  • Loading branch information
defunctzombie committed Jan 7, 2013
1 parent 1b94e72 commit b032ab1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions lib/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ module.exports.before = function(el, what) {
};

module.exports.empty = function(parent) {
var childNodes = parent.childNodes
for (var j=0 ; j<childNodes.length ; ++j) {
parent.removeChild(childNodes[j]);
}
// cheap way to remove all children
parent.innerHTML = '';
};

4 changes: 2 additions & 2 deletions test/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ test('replace save', function() {
suite('.empty');

test('empty', function() {
var div = dom('<div><p>foo</p></div>');
var div = dom('<div><p>foo</p><p>bar</p></div>');
var p = div.find('p');

assert.equal('<p>foo</p>', div.html());
assert.equal('<p>foo</p><p>bar</p>', div.html());
div.empty();
assert.equal('', div.html());
});
Expand Down

0 comments on commit b032ab1

Please sign in to comment.