OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset=utf-8> | 2 <script src="../../../resources/testharness.js"></script> |
3 <title>ParentNode.append</title> | 3 <script src="../../../resources/testharnessreport.js"></script> |
4 <link rel=help href="https://dom.spec.whatwg.org/#dom-parentnode-append"> | |
5 <script src="../../../../resources/testharness.js"></script> | |
6 <script src="../../../../resources/testharnessreport.js"></script> | |
7 <script> | 4 <script> |
8 | 5 |
| 6 test(function () { |
| 7 var node = document.createElement('div'); |
| 8 assert_true('append' in node); |
| 9 var append = 'mine'; |
| 10 var getAttribute = 'mine'; |
| 11 with (node) { |
| 12 assert_true(append === 'mine'); |
| 13 assert_false(getAttribute === 'mine'); |
| 14 } |
| 15 assert_true('Symbol' in window); |
| 16 var unscopables = Object.getPrototypeOf(node)[Symbol.unscopables]; |
| 17 assert_true(unscopables.append); |
| 18 }, 'ChildNode.append() unscopeable'); |
| 19 |
9 function test_append(node, nodeName) { | 20 function test_append(node, nodeName) { |
10 | 21 |
11 test(function() { | 22 test(function() { |
12 var parent = node.cloneNode(); | 23 var parent = node.cloneNode(); |
13 parent.append(); | 24 parent.append(); |
14 assert_array_equals(parent.childNodes, []); | 25 assert_array_equals(parent.childNodes, []); |
15 }, nodeName + '.append() without any argument, on a parent having no child.'
); | 26 }, nodeName + '.append() without any argument, on a parent having no child.'
); |
16 | 27 |
17 test(function() { | 28 test(function() { |
18 var parent = node.cloneNode(); | 29 var parent = node.cloneNode(); |
(...skipping 26 matching lines...) Expand all Loading... |
45 parent.appendChild(child); | 56 parent.appendChild(child); |
46 parent.append(null); | 57 parent.append(null); |
47 assert_equals(parent.childNodes[0], child); | 58 assert_equals(parent.childNodes[0], child); |
48 assert_equals(parent.childNodes[1].textContent, 'null'); | 59 assert_equals(parent.childNodes[1].textContent, 'null'); |
49 }, nodeName + '.append() with null as an argument, on a parent having a chil
d.'); | 60 }, nodeName + '.append() with null as an argument, on a parent having a chil
d.'); |
50 | 61 |
51 test(function() { | 62 test(function() { |
52 var parent = node.cloneNode(); | 63 var parent = node.cloneNode(); |
53 var x = document.createElement('x'); | 64 var x = document.createElement('x'); |
54 var child = document.createElement('test'); | 65 var child = document.createElement('test'); |
| 66 parent.appendChild(x); |
| 67 parent.appendChild(child); |
| 68 parent.append(child, x); |
| 69 assert_array_equals(parent.childNodes, [child, x]); |
| 70 }, nodeName + '.append() with all children as arguments, on a parent having
two children.'); |
| 71 |
| 72 test(function() { |
| 73 var parent = node.cloneNode(); |
| 74 var x = document.createElement('x'); |
| 75 var child = document.createElement('test'); |
55 parent.appendChild(child); | 76 parent.appendChild(child); |
56 parent.append(x, 'text'); | 77 parent.append(x, 'text'); |
57 assert_equals(parent.childNodes[0], child); | 78 assert_equals(parent.childNodes[0], child); |
58 assert_equals(parent.childNodes[1], x); | 79 assert_equals(parent.childNodes[1], x); |
59 assert_equals(parent.childNodes[2].textContent, 'text'); | 80 assert_equals(parent.childNodes[2].textContent, 'text'); |
60 }, nodeName + '.append() with one element and text as argument, on a parent
having a child.'); | 81 }, nodeName + '.append() with one element and text as argument, on a parent
having a child.'); |
61 } | 82 } |
62 | 83 |
63 test_append(document.createElement('div'), 'Element'); | 84 test_append(document.createElement('div'), 'Element'); |
64 test_append(document.createDocumentFragment(), 'DocumentFrgment'); | 85 test_append(document.createDocumentFragment(), 'DocumentFrgment'); |
65 </script> | 86 </script> |
66 </html> | 87 </html> |
OLD | NEW |