Automatic update from web-platform-tests [@scope] Expand :scope selectors for :has() cache The :scope pseudo-class can refer to different elements depending on context. This is similar to the '&' pseudo-class, but differs in that :scope refers to a single *element*, not a specific selector list. This causes problems for the :has() cache, since it uses the serialization of a selector as the key. In CL:5680906, this was solved by expanding '&' in the cache-key, and this CL now does a similar trick for :scope. Unlike '&', however, the :scope selector itself does not know what it refers to; it must come from context. We can use the pointer value of the scope node for this, since the :has() cache only exists on the stack during style recalc. Fixed: 383343312 Change-Id: I08e5d3caf18831d614caed474081d32caa43bd64 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6090905 Reviewed-by: Byungwoo Lee <blee@igalia.com> Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1397188} -- wpt-commits: b9ff3b3521376a66d4765bd2765928c549d3df09 wpt-pr: 49721
34 lines
1000 B
HTML
34 lines
1000 B
HTML
<!DOCTYPE html>
|
|
<title>@scope - Overlapping scopes with :has(..:scope..) selector</title>
|
|
<link rel="help" href="https://drafts.csswg.org/css-cascade-6/#scope-atrule">
|
|
<link rel="help" href="https://issues.chromium.org/issues/383343312">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<style>
|
|
:where(*) {
|
|
background-color: green;
|
|
}
|
|
@scope (.a) to (.limit) {
|
|
:scope:has(.b:not(:scope .a *)) .hello {
|
|
background-color: red;
|
|
}
|
|
}
|
|
</style>
|
|
<div class=a id=outer>
|
|
<div>
|
|
<div class=limit>
|
|
<div class=a id=inner>
|
|
<div class=b></div>
|
|
<div class=hello id=first>hello</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class=hello id=second>hello</div>
|
|
</div>
|
|
<script>
|
|
test(() => {
|
|
assert_equals(getComputedStyle(first).backgroundColor, 'rgb(255, 0, 0)');
|
|
assert_equals(getComputedStyle(second).backgroundColor, 'rgb(0, 128, 0)');
|
|
}, ':has() with inner :scope works when scopes overlap');
|
|
</script>
|