зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1917089: Let nested @scope rule to use relative selector in scope-start. r=firefox-style-system-reviewers,emilio
Depends on D221253 Differential Revision: https://phabricator.services.mozilla.com/D221254
This commit is contained in:
Родитель
bc34853aa8
Коммит
ded398854c
|
@ -729,7 +729,7 @@ impl<'a, 'i> AtRuleParser<'i> for NestedRuleParser<'a, 'i> {
|
|||
AtRulePrelude::Document(cond)
|
||||
},
|
||||
"scope" if static_prefs::pref!("layout.css.at-scope.enabled") => {
|
||||
let bounds = ScopeBounds::parse(&self.context, input, self.in_style_rule())?;
|
||||
let bounds = ScopeBounds::parse(&self.context, input, self.parse_relative())?;
|
||||
AtRulePrelude::Scope(bounds)
|
||||
},
|
||||
"starting-style" if static_prefs::pref!("layout.css.starting-style-at-rules.enabled") => {
|
||||
|
|
|
@ -113,7 +113,7 @@ impl ScopeBounds {
|
|||
fn parse_scope<'a>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'a, '_>,
|
||||
in_style_rule: bool,
|
||||
parse_relative: ParseRelative,
|
||||
for_end: bool,
|
||||
) -> Result<Option<SelectorList<SelectorImpl>>, ParseError<'a>> {
|
||||
input
|
||||
|
@ -145,10 +145,8 @@ fn parse_scope<'a>(
|
|||
};
|
||||
let parse_relative = if for_end {
|
||||
ParseRelative::ForScope
|
||||
} else if in_style_rule {
|
||||
ParseRelative::ForNesting
|
||||
} else {
|
||||
ParseRelative::No
|
||||
parse_relative
|
||||
};
|
||||
Ok(Some(SelectorList::parse_disallow_pseudo(
|
||||
&selector_parser,
|
||||
|
@ -164,10 +162,10 @@ impl ScopeBounds {
|
|||
pub fn parse<'a>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'a, '_>,
|
||||
in_style_rule: bool,
|
||||
parse_relative: ParseRelative,
|
||||
) -> Result<Self, ParseError<'a>> {
|
||||
let start = parse_scope(context, input, in_style_rule, false)?;
|
||||
let end = parse_scope(context, input, in_style_rule, true)?;
|
||||
let start = parse_scope(context, input, parse_relative, false)?;
|
||||
let end = parse_scope(context, input, parse_relative, true)?;
|
||||
Ok(Self { start, end })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -542,3 +542,37 @@ test((t) => {
|
|||
assert_equals(getComputedStyle(b_inside).zIndex, '1');
|
||||
}, 'Scoped nested group rule');
|
||||
</script>
|
||||
|
||||
<template id=test_scoped_within_scoped>
|
||||
<div>
|
||||
<style>
|
||||
@scope (.a) {
|
||||
@scope(#descendant) {
|
||||
:scope {
|
||||
z-index: 1;
|
||||
}
|
||||
}
|
||||
@scope (> #child) {
|
||||
:scope {
|
||||
z-index: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<div class="a">
|
||||
<div id="descendant">
|
||||
</div>
|
||||
<div id="child">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
test((t) => {
|
||||
t.add_cleanup(() => main.replaceChildren());
|
||||
main.append(test_scoped_within_scoped.content.cloneNode(true));
|
||||
|
||||
assert_equals(getComputedStyle(descendant).zIndex, '1');
|
||||
assert_equals(getComputedStyle(child).zIndex, '1');
|
||||
}, 'Scoped nested within another scope');
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче