OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <meta charset=utf-8> |
| 3 <title>MutationObservers: innerHTML, outerHTML mutations</title> |
| 4 <script src="../../../../resources/testharness.js"></script> |
| 5 <script src="../../../../resources/testharnessreport.js"></script> |
| 6 <script src="mutationobservers.js"></script> |
| 7 <h1>MutationObservers: innerHTML, outerHTML mutations</h1> |
| 8 <div id="log"></div> |
| 9 |
| 10 <section style="display: none"> |
| 11 |
| 12 <p id='n00'>old text</p> |
| 13 |
| 14 <p id='n01'>old text</p> |
| 15 |
| 16 <div id='n02'><p>old text</p></div> |
| 17 </section> |
| 18 |
| 19 <script> |
| 20 var n00; |
| 21 var n00oldText; |
| 22 var n01; |
| 23 var n01oldText; |
| 24 var n02; |
| 25 |
| 26 setup(function() { |
| 27 n00 = document.getElementById('n00'); |
| 28 n00oldText = n00.firstChild; |
| 29 n01 = document.getElementById('n01'); |
| 30 n01oldText = n01.firstChild; |
| 31 n02 = document.getElementById('n02'); |
| 32 }) |
| 33 |
| 34 runMutationTest(n00, |
| 35 {childList:true,attributes:true}, |
| 36 [{type: "childList", |
| 37 removedNodes: [n00oldText], |
| 38 addedNodes: function() { |
| 39 return [document.getElementById("n00").firstChild]; |
| 40 }}, |
| 41 {type: "attributes", attributeName: "class"}], |
| 42 function() { n00.innerHTML = "new text"; n00.className = "c01"
}, |
| 43 "innerHTML mutation"); |
| 44 |
| 45 runMutationTest(n01, |
| 46 {childList:true}, |
| 47 [{type: "childList", |
| 48 removedNodes: [n01oldText], |
| 49 addedNodes: function() { |
| 50 return [document.getElementById("n01").firstChild, |
| 51 document.getElementById("n01").lastChild]; |
| 52 }}], |
| 53 function() { n01.innerHTML = "<span>new</span><span>text</span
>"; }, |
| 54 "innerHTML with 2 children mutation"); |
| 55 |
| 56 runMutationTest(n02, |
| 57 {childList:true}, |
| 58 [{type: "childList", |
| 59 removedNodes: [n02.firstChild], |
| 60 addedNodes: function() { |
| 61 return [n02.firstChild]; |
| 62 }}], |
| 63 function() { n02.firstChild.outerHTML = "<p>next text</p>"; }, |
| 64 "outerHTML mutation"); |
| 65 </script> |
OLD | NEW |