Skip to content

Commit e7e6e63

Browse files
andruudmoz-wptsync-bot
authored andcommitted
Bug 1818014 [wpt PR 38610] - [@scope] Support @scope (:host), a=testonly
Automatic update from web-platform-tests [@scope] Support @scope (:host) In CalculateActivations, we'd previously just call Element.parentElement up the ancestor chain, therefore never reach the host. Additionally, we did not propagate the original SelectorCheckerContext.scope which is needed for :host to match. This CL uses ParentOrShadowHostElement, and adds the concept of "activation ceiling" to deal with the fact that we need to look at one element *above* the current activation root when that root is a ShadowRoot. Note that :scope is supposed to be able to match "virtual" roots [1] (like a ShadowRoot), but Blink does not support this in general. This CL does not address this issue. [1] w3c/csswg-drafts#7261 Bug: 1280240 Change-Id: I2d0be103f4cd02ec576711b959e075a5118e694a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4272396 Commit-Queue: Anders Hartvoll Ruud Reviewed-by: Rune Lillesveen Cr-Commit-Position: refs/heads/main@{#1108363} -- wpt-commits: 37ffe7edc5b6400a16ba6511ba2fd392ab8be318 wpt-pr: 38610
1 parent 3bd2f17 commit e7e6e63

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
>
2+
<title>@scope - ShadowDOMtitle>
3+
<link rel="help" href="https://drafts.csswg.org/css-cascade-6/#scope-atrule">
4+
<script src="/resources/testharness.js">script>
5+
<script src="/resources/testharnessreport.js">script>
6+
<script src="/resources/declarative-shadow-dom-polyfill.js">script>
7+
8+
<div id=host_plain>
9+
<template shadowroot=open>
10+
<style>
11+
@scope (:host) {
12+
.a {
13+
z-index: 1;
14+
}
15+
}
16+
style>
17+
<div class=a>
18+
div>
19+
template>
20+
div>
21+
<script>
22+
setup(() => {
23+
polyfill_declarative_shadow_dom(document);
24+
});
25+
26+
test(() => {
27+
let a = host_plain.shadowRoot.querySelector('.a');
28+
assert_equals(getComputedStyle(a).zIndex, '1');
29+
}, '@scope can match :host');
30+
script>
31+
32+
<div id=host_functional>
33+
<template shadowroot=open>
34+
<style>
35+
@scope (:host(div)) {
36+
.a {
37+
z-index: 1;
38+
}
39+
}
40+
/* Should not match: */
41+
@scope (:host(span)) {
42+
.a {
43+
z-index: 42;
44+
}
45+
}
46+
style>
47+
<div class=a>
48+
div>
49+
template>
50+
div>
51+
<script>
52+
setup(() => {
53+
polyfill_declarative_shadow_dom(document);
54+
});
55+
56+
test(() => {
57+
let a = host_functional.shadowRoot.querySelector('.a');
58+
assert_equals(getComputedStyle(a).zIndex, '1');
59+
}, '@scope can match :host(...)');
60+
script>

0 commit comments

Comments
 (0)