-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathscope-implicit.html
More file actions
91 lines (84 loc) · 2.08 KB
/
scope-implicit.html
File metadata and controls
91 lines (84 loc) · 2.08 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<title>@scope - implicit scope root</title>
<link rel="help" href="https://drafts.csswg.org/css-cascade-6/#scope-atrule">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<main id=main></main>
<template id=test_basic>
<div>
<style>
@scope {
.a { z-index:1; }
}
</style>
<div id=inner class=a></div>
</div>
<div id=outer class=a></div>
</template>
<script>
test((t) => {
t.add_cleanup(() => main.replaceChildren());
main.append(test_basic.content.cloneNode(true));
assert_equals(getComputedStyle(inner).zIndex, '1');
assert_equals(getComputedStyle(outer).zIndex, 'auto');
}, '@scope without prelude implicitly scopes to parent of owner node');
</script>
<template id=test_scope_pseudo>
<div>
<div></div>
</div>
<div>
<div id=root>
<style>
@scope {
:scope { z-index:1; }
}
</style>
<div>
<div></div>
</div>
</div>
</div>
<div>
<div></div>
</div>
</template>
<script>
test((t) => {
t.add_cleanup(() => main.replaceChildren());
main.append(test_scope_pseudo.content.cloneNode(true));
assert_equals(getComputedStyle(root).zIndex, '1');
// Only #root should be affected.
for (let div of main.querySelectorAll('div:not(#root)')) {
assert_equals(getComputedStyle(div).zIndex, 'auto');
}
}, ':scope can style implicit root');
</script>
<template id=test_duplicate>
<div>
<style>
@scope {
.a { z-index:1; }
}
</style>
<div id=first class=a></div>
</div>
<div>
<style>
@scope {
.a { z-index:1; }
}
</style>
<div id=second class=a></div>
</div>
<div id=outer class=a></div>
</template>
<script>
test((t) => {
t.add_cleanup(() => main.replaceChildren());
main.append(test_duplicate.content.cloneNode(true));
assert_equals(getComputedStyle(first).zIndex, '1');
assert_equals(getComputedStyle(second).zIndex, '1');
assert_equals(getComputedStyle(outer).zIndex, 'auto');
}, '@scope works with two identical stylesheets');
</script>