/
shadow-dom.html
51 lines (47 loc) · 2.27 KB
/
shadow-dom.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html>
<head>
<title>Shadow DOM Fixture</title>
</head>
<body>
<div id="non-shadow-element" class="in-and-out">Non Shadow</div>
<cy-test-element id="shadow-element-1" innerClass="shadow-1" content="Shadow Content 1"></cy-test-element>
<cy-test-element id="shadow-element-2" innerClass="shadow-2" content="Shadow Content 2"></cy-test-element>
<div id="parent-of-shadow-container-0">
<div id="parent-of-shadow-container-1">
<cy-test-element id="shadow-element-3" innerClass="shadow-3" content="Shadow Content 3"></cy-test-element>
</div>
</div>
<cy-test-element innerClass="shadow-4" content="Shadow Content 4">
<cy-test-element innerClass="shadow-5" content="Shadow Content 5"></cy-test-element>
</cy-test-element>
<cy-test-element innerClass="shadow-6" content="Shadow Content 6">
<div class="in-shadow-slot">In Shadow Slot</div>
</cy-test-element>
<cy-test-element id="shadow-element-7" innerClass="in-and-out" content="Shadow Content 7"></cy-test-element>
<div class="focusable" tabindex="1">
<cy-test-element innerClass="inside-focusable" content="Inside Focusable"></cy-test-element>
</div>
<cy-test-element innerClass="inside-non-visible" content="Not Visible" style="transform-style: preserve-3d; backface-visibility: hidden; transform: rotateY(180deg);"></cy-test-element>
<script type="text/javascript">
if (window.customElements) {
window.customElements.define('cy-test-element', class extends HTMLElement {
constructor () {
super()
const root = this.attachShadow({ mode: 'open' })
const para = document.createElement('p')
const content = this.getAttribute('content') || 'Shadow Content'
const className = this.hasAttribute('innerClass') ? this.getAttribute('innerClass') : 'shadow-content'
root.innerHTML = `<p class="${className}">${content}</p><input /><slot></slot>`
}
})
}
if (window.location.search.includes('wrap-qsa')) {
const realQuerySelectorAll = document.querySelectorAll;
document.querySelectorAll = function (...args) {
return realQuerySelectorAll.apply(document, args);
};
}
</script>
</body>
</html>