Bug 1822990 [wpt PR 39050] - [@scope] Allow CSSNestingType::kScope without having a parent rule, a=testonly

Automatic update from web-platform-tests
[@scope] Allow CSSNestingType::kScope without having a parent rule

Scopes without a <scope-start> selector are scoped to the owner node's
parent. The selectors within such @scope rules should parse according
to the behavior of CSSNestingType::kScope (i.e. relative rules allowed,
implicit :scope descendant if needed), even though there is no
parent rule. Therefore this CL changes CSSSelectorParser to check
for `nesting_type` instead of `parent_rule_for_nesting` when setting
the initial value of in_nested_style_rule.

Bug: 1280240
Change-Id: Ie8d90b8ef059e519919b89a13b93d340d0917d8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4345880
Reviewed-by: Steinar H Gunderson <sesse@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1119277}

--

wpt-commits: e9ef5fdaa91bd718b3479f437015d5c82dce85ea
wpt-pr: 39050
This commit is contained in:
Anders Hartvoll Ruud 2023-03-20 20:19:41 +00:00 коммит произвёл moz-wptsync-bot
Родитель e65bd291e2
Коммит c1bbe5c478
1 изменённых файлов: 62 добавлений и 0 удалений

Просмотреть файл

@ -109,3 +109,65 @@ test((t) => {
assert_equals(getComputedStyle(a).zIndex, 'auto');
}, '@scope with effectively empty :is() must not match anything');
</script>
<template id=test_implicit_descendant>
<div id=div>
<style>
@scope {
#div { z-index:1; }
}
</style>
</div>
</template>
<script>
test((t) => {
t.add_cleanup(() => main.replaceChildren());
main.append(test_implicit_descendant.content.cloneNode(true));
assert_equals(getComputedStyle(div).zIndex, 'auto');
}, 'Implicit @scope has implicitly added :scope descendant combinator');
</script>
<template id=test_implicit_relative>
<div id=outer>
<style>
@scope {
> div { z-index:1; }
}
</style>
<div id=child>
<div id=inner></div>
</div>
</div>
</template>
<script>
test((t) => {
t.add_cleanup(() => main.replaceChildren());
main.append(test_implicit_relative.content.cloneNode(true));
assert_equals(getComputedStyle(outer).zIndex, 'auto');
assert_equals(getComputedStyle(child).zIndex, '1');
assert_equals(getComputedStyle(inner).zIndex, 'auto');
}, 'Implicit @scope with inner relative selector');
</script>
<template id=test_implicit_descendant_nesting_selector>
<div id=div>
<style>
@scope {
/* Behaves like :scope */
& { z-index:1; }
}
</style>
<div id=inner></div>
</div>
</template>
<script>
test((t) => {
t.add_cleanup(() => main.replaceChildren());
main.append(test_implicit_descendant_nesting_selector.content.cloneNode(true));
assert_equals(getComputedStyle(div).zIndex, '1');
assert_equals(getComputedStyle(inner).zIndex, 'auto');
}, 'Implicit @scope with inner nesting selector');
</script>