OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
2 <html> | |
3 <head> | |
4 <script src="../../resources/js-test.js"></script> | |
5 </head> | |
6 <body> | |
7 <p id="description"></p> | |
8 <div id="console"></div> | |
9 <script> | |
10 description('Tests that setting .length on an HTMLSelectElement works in the pre
sence of mutation event listeners that reparent options'); | |
11 | |
12 var sel = document.createElement('select'); | |
13 document.body.appendChild(sel); | |
14 var otherSel = document.createElement('select'); | |
15 document.body.appendChild(otherSel); | |
16 | |
17 function onRemove(e) { | |
18 if (e.target.nextSibling != null) { | |
19 // remove listener temporarily to avoid lots of nesting | |
20 sel.removeEventListener('DOMNodeRemoved', onRemove, false); | |
21 var n = e.target.nextSibling; | |
22 n.parentNode.removeChild(n); | |
23 otherSel.appendChild(n); | |
24 sel.addEventListener('DOMNodeRemoved', onRemove, false); | |
25 } | |
26 } | |
27 | |
28 sel.addEventListener('DOMNodeRemoved', onRemove, false); | |
29 sel.addEventListener('DOMNodeInserted', function() {}, false); | |
30 | |
31 sel.length = 200; | |
32 shouldBe('sel.length', '200'); | |
33 shouldBe('otherSel.length', '0'); | |
34 | |
35 sel.length = 100; | |
36 shouldBe('sel.length', '100'); | |
37 shouldBe('otherSel.length', '0'); | |
38 | |
39 sel.length = 180; | |
40 shouldBe('sel.length', '180'); | |
41 shouldBe('otherSel.length', '0'); | |
42 </script> | |
43 </body> | |
44 </html> | |
OLD | NEW |