diff --git a/src/wrappers/HTMLSelectElement.js b/src/wrappers/HTMLSelectElement.js index 584635c..72c32a2 100644 --- a/src/wrappers/HTMLSelectElement.js +++ b/src/wrappers/HTMLSelectElement.js @@ -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); }, diff --git a/test/js/HTMLSelectElement.js b/test/js/HTMLSelectElement.js index 0c07d1f..f6f18e3 100644 --- a/test/js/HTMLSelectElement.js +++ b/test/js/HTMLSelectElement.js @@ -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); + }); + });