forked from mirrors/gecko-dev
Bug 1882581: Allow parsing scope-end selector as relative, anchoring at :scope. r=firefox-style-system-reviewers,emilio
WPT is adjusted to reflect the resolution of Issue #9621 (https://github.com/w3c/csswg-drafts/issues/9621). That is, relative selectors are serialized with `:scope` e.g. `> .foo` becomes `:scope > .foo`. Differential Revision: https://phabricator.services.mozilla.com/D203154
This commit is contained in:
parent
1e31a04af4
commit
9814aed542
3 changed files with 14 additions and 7 deletions
|
|
@ -438,6 +438,9 @@ pub enum ParseRelative {
|
||||||
/// Allow selectors to start with a combinator, prepending a parent selector if so. Do nothing
|
/// Allow selectors to start with a combinator, prepending a parent selector if so. Do nothing
|
||||||
/// otherwise
|
/// otherwise
|
||||||
ForNesting,
|
ForNesting,
|
||||||
|
/// Allow selectors to start with a combinator, prepending a scope selector if so. Do nothing
|
||||||
|
/// otherwise
|
||||||
|
ForScope,
|
||||||
/// Treat as parse error if any selector begins with a combinator.
|
/// Treat as parse error if any selector begins with a combinator.
|
||||||
No,
|
No,
|
||||||
}
|
}
|
||||||
|
|
@ -2619,9 +2622,14 @@ where
|
||||||
// combinator.
|
// combinator.
|
||||||
builder.push_combinator(combinator.unwrap_or(Combinator::Descendant));
|
builder.push_combinator(combinator.unwrap_or(Combinator::Descendant));
|
||||||
},
|
},
|
||||||
ParseRelative::ForNesting => {
|
ParseRelative::ForNesting | ParseRelative::ForScope => {
|
||||||
if let Ok(combinator) = combinator {
|
if let Ok(combinator) = combinator {
|
||||||
builder.push_simple_selector(Component::ParentSelector);
|
let selector = match parse_relative {
|
||||||
|
ParseRelative::ForHas | ParseRelative::No => unreachable!(),
|
||||||
|
ParseRelative::ForNesting => Component::ParentSelector,
|
||||||
|
ParseRelative::ForScope => Component::Scope,
|
||||||
|
};
|
||||||
|
builder.push_simple_selector(selector);
|
||||||
builder.push_combinator(combinator);
|
builder.push_combinator(combinator);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -119,8 +119,7 @@ fn parse_scope<'a>(
|
||||||
for_supports_rule: false,
|
for_supports_rule: false,
|
||||||
};
|
};
|
||||||
let parse_relative = if for_end {
|
let parse_relative = if for_end {
|
||||||
// TODO(dshin): scope-end can be a relative selector, with the anchor being `:scope`.
|
ParseRelative::ForScope
|
||||||
ParseRelative::No
|
|
||||||
} else if in_style_rule {
|
} else if in_style_rule {
|
||||||
ParseRelative::ForNesting
|
ParseRelative::ForNesting
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,9 @@
|
||||||
test_valid('@scope to (.a)');
|
test_valid('@scope to (.a)');
|
||||||
test_valid('@scope (.a) to (&)');
|
test_valid('@scope (.a) to (&)');
|
||||||
test_valid('@scope (.a) to (& > &)');
|
test_valid('@scope (.a) to (& > &)');
|
||||||
test_valid('@scope (.a) to (> .b)');
|
test_valid('@scope (.a) to (> .b)', '@scope (.a) to (:scope > .b)');
|
||||||
test_valid('@scope (.a) to (+ .b)');
|
test_valid('@scope (.a) to (+ .b)', '@scope (.a) to (:scope + .b)');
|
||||||
test_valid('@scope (.a) to (~ .b)');
|
test_valid('@scope (.a) to (~ .b)', '@scope (.a) to (:scope ~ .b)');
|
||||||
test_valid('@scope ()', '@scope');
|
test_valid('@scope ()', '@scope');
|
||||||
test_valid('@scope to ()', '@scope');
|
test_valid('@scope to ()', '@scope');
|
||||||
test_valid('@scope () to ()', '@scope');
|
test_valid('@scope () to ()', '@scope');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue