Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/build-prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ let mdnFeatures = {
oklabColors: mdn.css.types.color.oklab.__compat.support,
colorFunction: mdn.css.types.color.color.__compat.support,
spaceSeparatedColorNotation: mdn.css.types.color.rgb.space_separated_parameters.__compat.support,
highlight: mdn.css.selectors.highlight.__compat.support,
textDecorationThicknessPercent: mdn.css.properties['text-decoration-thickness'].percentage.__compat.support,
textDecorationThicknessShorthand: mdn.css.properties['text-decoration'].includes_thickness.__compat.support,
cue: mdn.css.selectors.cue.__compat.support,
Expand Down
4 changes: 4 additions & 0 deletions selectors/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3933,6 +3933,10 @@ pub mod tests {
assert!(parse("foo::details-content").is_ok());
assert!(parse("foo::target-text").is_ok());

assert!(parse("::highlight").is_err());
assert!(parse("::highlight()").is_err());
assert!(parse("::highlight(custom-highlight-name)").is_ok());

assert!(parse("select::picker").is_err());
assert!(parse("::picker()").is_err());
assert!(parse("::picker(select)").is_ok());
Expand Down
46 changes: 46 additions & 0 deletions src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ pub enum Feature {
HasSelector,
HebrewListStyleType,
HexAlphaColors,
Highlight,
HiraganaIrohaListStyleType,
HiraganaListStyleType,
HypotFunction,
Expand Down Expand Up @@ -2455,6 +2456,51 @@ impl Feature {
return false;
}
}
Feature::Highlight => {
if let Some(version) = browsers.chrome {
if version < 6881280 {
return false;
}
}
if let Some(version) = browsers.edge {
if version < 6881280 {
return false;
}
}
if let Some(version) = browsers.firefox {
if version < 9175040 {
return false;
}
}
if let Some(version) = browsers.opera {
if version < 4718592 {
return false;
}
}
if let Some(version) = browsers.safari {
if version < 1114624 {
return false;
}
}
if let Some(version) = browsers.ios_saf {
if version < 1114624 {
return false;
}
}
if let Some(version) = browsers.samsung {
if version < 1310720 {
return false;
}
}
if let Some(version) = browsers.android {
if version < 6881280 {
return false;
}
}
if browsers.ie.is_some() {
return false;
}
}
Feature::TextDecorationThicknessPercent => {
if let Some(version) = browsers.chrome {
if version < 5701632 {
Expand Down
12 changes: 12 additions & 0 deletions src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ impl<'a, 'o, 'i> parcel_selectors::parser::Parser<'i> for SelectorParser<'a, 'o,
let pseudo_element = match_ignore_ascii_case! { &name,
"cue" => CueFunction { selector: Box::new(Selector::parse(self, arguments)?) },
"cue-region" => CueRegionFunction { selector: Box::new(Selector::parse(self, arguments)?) },
"highlight" => HighlightFunction { name: CustomIdent::parse(arguments)? },
"picker" => PickerFunction { identifier: Ident::parse(arguments)? },
"view-transition-group" => ViewTransitionGroup { part: ViewTransitionPartSelector::parse(arguments)? },
"view-transition-image-pair" => ViewTransitionImagePair { part: ViewTransitionPartSelector::parse(arguments)? },
Expand Down Expand Up @@ -906,6 +907,11 @@ pub enum PseudoElement<'i> {
/// The [::placeholder](https://drafts.csswg.org/css-pseudo-4/#placeholder-pseudo) pseudo element.
#[cfg_attr(feature = "serde", serde(with = "PrefixWrapper"))]
Placeholder(VendorPrefix),
/// The [::highlight()](https://drafts.csswg.org/css-highlight-api/#custom-highlight-pseudo) functional pseudo element.
HighlightFunction {
/// A custom highlight name.
name: CustomIdent<'i>,
},
/// The [::marker](https://drafts.csswg.org/css-pseudo-4/#marker-pseudo) pseudo element.
Marker,
/// The [::backdrop](https://fullscreen.spec.whatwg.org/#::backdrop-pseudo-element) pseudo element.
Expand Down Expand Up @@ -1167,6 +1173,11 @@ where
FirstLetter => dest.write_str(":first-letter"),
DetailsContent => dest.write_str("::details-content"),
TargetText => dest.write_str("::target-text"),
HighlightFunction { name } => {
dest.write_str("::highlight(")?;
name.to_css(dest)?;
dest.write_char(')')
}
Marker => dest.write_str("::marker"),
Selection(prefix) => write_prefixed!(prefix, "selection"),
Cue => dest.write_str("::cue"),
Expand Down Expand Up @@ -1944,6 +1955,7 @@ pub(crate) fn is_compatible(selectors: &[Selector], targets: Targets) -> bool {
PseudoElement::TargetText => Feature::TargetText,
PseudoElement::Selection(prefix) if *prefix == VendorPrefix::None => Feature::Selection,
PseudoElement::Placeholder(prefix) if *prefix == VendorPrefix::None => Feature::Placeholder,
PseudoElement::HighlightFunction { name: _ } => Feature::Highlight,
PseudoElement::Marker => Feature::MarkerPseudo,
PseudoElement::Backdrop(prefix) if *prefix == VendorPrefix::None => Feature::Dialog,
PseudoElement::Cue => Feature::Cue,
Expand Down
Loading