Skip to content

Commit bc19e8e

Browse files
authored
Test for a nested :scope inside an :is() (#43697)
1 parent a8eb8ed commit bc19e8e

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

‎css/css-cascade/scope-nesting.html

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,51 @@
371371
assert_equals(getComputedStyle(c).zIndex, 'auto');
372372
}, 'Implicit rule within nested @scope (proximity)');
373373
</script>
374+
375+
<template id=test_nested_scope_inside_an_is>
376+
<div>
377+
<style>
378+
@scope (.a) {
379+
.b {
380+
/* When nesting, because we’re inside a defined scope,
381+
the `:scope` should reference the scoping root node properly, and
382+
check for the presence of an extra class on it, essentially
383+
being equal to `:scope.x .b { z-index: 1 }`. */
384+
&:is(:scope.x *) {
385+
z-index: 1;
386+
}
387+
/* This should not match, as we have a defined scope, and should
388+
not skip to the root. */
389+
&:is(:root:scope *) {
390+
z-index: 2;
391+
}
392+
}
393+
/* The nested case can be though of the following when expanded: */
394+
.c:is(:scope.x *) {
395+
z-index: 3;
396+
}
397+
}
398+
</style>
399+
<div class="b">
400+
</div>
401+
<div class="a x">
402+
<div class="b">
403+
</div>
404+
<div class="c">
405+
</div>
406+
</div>
407+
</div>
408+
</template>
409+
<script>
410+
test((t) => {
411+
t.add_cleanup(() => main.replaceChildren());
412+
main.append(test_nested_scope_inside_an_is.content.cloneNode(true));
413+
414+
let b_outside = document.querySelector('.b');
415+
let b_inside = document.querySelector('.a .b');
416+
let c = document.querySelector('.c');
417+
assert_equals(getComputedStyle(b_outside).zIndex, 'auto');
418+
assert_equals(getComputedStyle(b_inside).zIndex, '1');
419+
assert_equals(getComputedStyle(c).zIndex, '3');
420+
}, 'Nested :scope inside an :is');
421+
</script>

0 commit comments

Comments
 (0)