1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
<!doctype html>
<meta charset=utf-8>
<title>HTMLSelectElement.remove</title>
<link rel="author" title="Ms2ger" href="Ms2ger@gmail.com">
<link rel="help" href="https://dom.spec.whatwg.org/#dom-childnode-remove">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-select-remove">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-htmloptionscollection-remove">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
function testRemove(getter, desc) {
test(function() {
var div = document.createElement("div");
var select = document.createElement("select");
div.appendChild(select);
assert_equals(select.parentNode, div);
var options = [];
for (var i = 0; i < 3; ++i) {
var option = document.createElement("option");
option.textContent = String(i);
select.appendChild(option);
options.push(option);
}
getter(select).remove(-1);
assert_array_equals(select.options, options, "After remove(-1)");
assert_equals(select.parentNode, div);
getter(select).remove(3);
assert_array_equals(select.options, options, "After remove(3)");
assert_equals(select.parentNode, div);
getter(select).remove(0);
assert_array_equals(select.options, [options[1], options[2]], "After remove(0)");
assert_equals(select.parentNode, div);
}, desc)
}
testRemove(function(select) { return select; }, "select.remove(n) should work");
testRemove(function(select) { return select.options; }, "select.options.remove(n) should work");
test(function() {
var div = document.createElement("div");
var select = document.createElement("select");
div.appendChild(select);
assert_equals(select.parentNode, div);
assert_equals(div.firstChild, select);
select.remove();
assert_equals(select.parentNode, null);
assert_equals(div.firstChild, null);
}, "remove() should work on select elements.")
test(function() {
var div = document.createElement("div");
var select = document.createElement("select");
div.appendChild(select);
assert_equals(select.parentNode, div);
assert_equals(div.firstChild, select);
Element.prototype.remove.call(select);
assert_equals(select.parentNode, null);
assert_equals(div.firstChild, null);
}, "Element#remove() should work on select elements.")
</script>
|