mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-04 18:23:39 +00:00
LibWeb/CSS: Implement aliases for pseudo-elements
We previously supported a few -webkit vendor-prefixed pseudo-elements. This patch adds those back, along with -moz equivalents, by aliasing them to standard ones. They behave identically, except for serializing with their original name, just like for unrecognized -webkit pseudo-elements. It's likely to be a while before the forms spec settles and authors start using the new pseudo-elements, so until then, we can still make use of styles they've written for the non-standard ones.
This commit is contained in:
parent
2c86fd539d
commit
193adee164
Notes:
github-actions[bot]
2025-03-24 09:51:08 +00:00
Author: https://github.com/AtkinsSJ
Commit: 193adee164
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4021
3 changed files with 89 additions and 3 deletions
|
@ -430,6 +430,20 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_pseudo_simple_selec
|
|||
};
|
||||
}
|
||||
|
||||
// Aliased pseudo-elements behave like their target pseudo-element, but serialize as themselves. So store their
|
||||
// name like we do for unknown -webkit pseudos below.
|
||||
if (auto pseudo_element = aliased_pseudo_element_from_string(pseudo_name); pseudo_element.has_value()) {
|
||||
// :has() is fussy about pseudo-elements inside it
|
||||
if (m_pseudo_class_context.contains_slow(PseudoClass::Has) && !is_has_allowed_pseudo_element(*pseudo_element)) {
|
||||
return ParseError::SyntaxError;
|
||||
}
|
||||
|
||||
return Selector::SimpleSelector {
|
||||
.type = Selector::SimpleSelector::Type::PseudoElement,
|
||||
.value = Selector::PseudoElementSelector { pseudo_element.release_value(), pseudo_name.to_string().to_ascii_lowercase() }
|
||||
};
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/selectors-4/#compat
|
||||
// All other pseudo-elements whose names begin with the string “-webkit-” (matched ASCII case-insensitively)
|
||||
// and that are not functional notations must be treated as valid at parse time. (That is, ::-webkit-asdf is
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue