OLD | NEW |
(Empty) | |
| 1 function testReplaceWith(node, parent, type) { |
| 2 test(function() { |
| 3 assert_true("replaceWith" in node); |
| 4 assert_equals(typeof node.replaceWith, "function"); |
| 5 assert_equals(node.replaceWith.length, 0); |
| 6 }, type + " should support replaceWith()"); |
| 7 test(function() { |
| 8 var x; |
| 9 if (type == 'element' || type == 'document-fragment') { |
| 10 x = document.createElement('x'); |
| 11 } |
| 12 if (type == 'comment') { |
| 13 x = document.createComment('x'); |
| 14 } |
| 15 if (type == 'text') { |
| 16 x = document.createTextNode('x'); |
| 17 } |
| 18 parent.appendChild(node); |
| 19 assert_equals(node.parentNode, parent, "Appended node should have a parent"); |
| 20 assert_array_equals(parentNode.childNodes, [node], "ParentNode should have 1 chi
ld node"); |
| 21 node.replaceWith(x); |
| 22 assert_array_equals(parentNode.childNodes, [x], "ParentNode should have 1 child
x"); |
| 23 }, "replaceWith() should work for " + type); |
| 24 } |
OLD | NEW |