|
| 1 | +test(t => { |
| 2 | + const style = document.body.appendChild(document.createElement("style")); |
| 3 | + const sheet = style.sheet; |
| 4 | + t.add_cleanup(() => style.remove()); |
| 5 | + assert_not_equals(sheet, null); |
| 6 | + style.appendChild(new Comment()); |
| 7 | + assert_not_equals(sheet, style.sheet); |
| 8 | +}, "Mutating the style element: inserting a Comment node"); |
| 9 | + |
| 10 | +test(t => { |
| 11 | + const style = document.body.appendChild(document.createElement("style")); |
| 12 | + t.add_cleanup(() => style.remove()); |
| 13 | + const comment = style.appendChild(new Comment()); |
| 14 | + const sheet = style.sheet; |
| 15 | + comment.appendData("x"); |
| 16 | + assert_not_equals(sheet, style.sheet); |
| 17 | +}, "Mutating the style element: mutating a Comment node"); |
| 18 | + |
| 19 | +test(t => { |
| 20 | + const style = document.body.appendChild(document.createElement("style")); |
| 21 | + t.add_cleanup(() => style.remove()); |
| 22 | + const text1 = style.appendChild(new Text("1")); |
| 23 | + const text2 = style.appendChild(new Text("2")); |
| 24 | + assert_equals(style.textContent, "12"); |
| 25 | + assert_equals(style.childNodes.length, 2); |
| 26 | + const sheet = style.sheet; |
| 27 | + style.normalize(); |
| 28 | + assert_equals(style.childNodes.length, 1); |
| 29 | + assert_not_equals(sheet, style.sheet); |
| 30 | +}, "Mutating the style element: using normalize()"); |
| 31 | + |
| 32 | +test(t => { |
| 33 | + const style = document.body.appendChild(document.createElement("style")); |
| 34 | + t.add_cleanup(() => style.remove()); |
| 35 | + const comment = style.appendChild(new Comment()); |
| 36 | + const sheet = style.sheet; |
| 37 | + comment.remove(); |
| 38 | + assert_not_equals(sheet, style.sheet); |
| 39 | +}, "Mutating the style element: removing a Comment node"); |
0 commit comments