blob: c5773561f5e3c480a114271af854adc47d74e368 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" class="reftest-wait">
<head>
</head>
<body>
<template id="template">
<style>
.a:empty + .b { color: green; }
</style>
<span class="a">Some text</span>
<span class="b">This should be green</span>
<slot/>
</template>
<custom-element id="foo"></custom-element>
<script>
customElements.define("custom-element", class extends HTMLElement {
constructor() {
super();
const template = document.getElementById("template");
const shadowRoot = this.attachShadow({mode: "open"})
.appendChild(template.content.cloneNode(true));
}
nixText() {
this.shadowRoot.children[1].textContent = "";
}
});
window.onload = function() {
var el = document.getElementById("foo");
// Flush its layout
el.offsetWidth;
el.nixText();
document.documentElement.className = "";
}
</script>
</body>
</html>
|