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

Commit

Permalink
HTMLSelectElement remove()
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Mar 11, 2014
1 parent ceabcc8 commit e9d497b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/wrappers/HTMLSelectElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@
remove: function(indexOrNode) {
// Spec only allows index but implementations allow index or node.
// remove() is also allowed which is same as remove(undefined)
if (indexOrNode === undefined) {
HTMLElement.prototype.remove.call(this);
return;
}

if (typeof indexOrNode === 'object')
indexOrNode = unwrap(indexOrNode);

unwrap(this).remove(indexOrNode);
},

Expand Down
20 changes: 20 additions & 0 deletions test/js/HTMLSelectElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,24 @@ suite('HTMLSelectElement', function() {
assert.equal(select.lastChild, b);
});

test('remove no args', function() {
var div = document.createElement('div');
var select = div.appendChild(document.createElement('select'));

var a = document.createElement('option');
a.text = 'a';
select.appendChild(a);
var b = document.createElement('option');
b.text = 'b';
select.appendChild(b);

assert.equal(select.parentNode, div);

select.remove();
assert.equal(select.firstChild, a);
assert.equal(select.lastChild, b);
assert.equal(select.parentNode, null);
assert.equal(div.firstChild, null);
});

});

0 comments on commit e9d497b

Please sign in to comment.