| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <style> |
| 5 div { |
| 6 color: black; |
| 7 } |
| 8 span:first-child { |
| 9 color: blue; |
| 10 } |
| 11 span:last-child { |
| 12 color: red; |
| 13 } |
| 14 </style> |
| 15 <div id="target"><span>first-initially</span><span>last-initially</span></div> |
| 16 <script> |
| 17 test(() => { |
| 18 let target = document.querySelector('#target'); |
| 19 let first = target.firstChild; |
| 20 assert_equals(getComputedStyle(first).color, 'rgb(0, 0, 255)'); |
| 21 target.insertAdjacentHTML('afterbegin', '\n<span>foo</span><span>bar</span>'); |
| 22 assert_equals(getComputedStyle(target.firstElementChild).color, 'rgb(0, 0, 255
)'); |
| 23 assert_equals(getComputedStyle(first).color, 'rgb(0, 0, 0)'); |
| 24 }, 'Adding multiple nodes at once should invalidate :first-child correctly.'); |
| 25 |
| 26 test(() => { |
| 27 let target = document.querySelector('#target'); |
| 28 let last = target.lastChild; |
| 29 assert_equals(getComputedStyle(last).color, 'rgb(255, 0, 0)'); |
| 30 target.insertAdjacentHTML('beforeend', '\n<span>foo</span><span>bar</span>'); |
| 31 assert_equals(getComputedStyle(target.lastChild).color, 'rgb(255, 0, 0)'); |
| 32 assert_equals(getComputedStyle(last).color, 'rgb(0, 0, 0)'); |
| 33 }, 'Adding multiple nodes at once should invalidate :last-child correctly.'); |
| 34 </script> |
| OLD | NEW |