Skip to content

Commit

Permalink
Add compat data for ::part
Browse files Browse the repository at this point in the history
Fixes #515
  • Loading branch information
devongovett committed Jun 17, 2023
1 parent cff779d commit fbf0d24
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
1 change: 1 addition & 0 deletions scripts/build-prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ let mdnFeatures = {
}
})
),
partPseudo: mdn.css.selectors.part.__compat.support,
imageSet: mdn.css.types.image['image-set'].__compat.support,
xResolutionUnit: mdn.css.types.resolution.x.__compat.support,
nthChildOf: mdn.css.selectors['nth-child'].of_syntax.__compat.support,
Expand Down
46 changes: 46 additions & 0 deletions src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub enum Feature {
OriyaListStyleType,
OverflowShorthand,
P3Colors,
PartPseudo,
PersianListStyleType,
PlaceContent,
PlaceItems,
Expand Down Expand Up @@ -2500,6 +2501,51 @@ impl Feature {
return false;
}
}
Feature::PartPseudo => {
if let Some(version) = browsers.chrome {
if version < 4784128 {
return false;
}
}
if let Some(version) = browsers.edge {
if version < 5177344 {
return false;
}
}
if let Some(version) = browsers.firefox {
if version < 5177344 {
return false;
}
}
if let Some(version) = browsers.opera {
if version < 3407872 {
return false;
}
}
if let Some(version) = browsers.safari {
if version < 852224 {
return false;
}
}
if let Some(version) = browsers.ios_saf {
if version < 852992 {
return false;
}
}
if let Some(version) = browsers.samsung {
if version < 720896 {
return false;
}
}
if let Some(version) = browsers.android {
if version < 4784128 {
return false;
}
}
if browsers.ie.is_some() {
return false;
}
}
Feature::ImageSet => {
if let Some(version) = browsers.chrome {
if version < 1638400 {
Expand Down
20 changes: 19 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9556,7 +9556,25 @@ mod tests {
Browsers {
safari: Some(12 << 16),
..Browsers::default()
}.into(),
}
.into(),
);

prefix_test(
r#"
.foo::part(header), .foo::part(body) {
display: none
}
"#,
indoc! {r#"
.foo::part(header), .foo::part(body) {
display: none;
}
"#},
Browsers {
safari: Some(14 << 16),
..Browsers::default()
},
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ pub(crate) fn is_compatible(selectors: &[Selector], targets: Targets) -> bool {

Component::Scope | Component::Host(_) | Component::Slotted(_) => Feature::Shadowdomv1,

Component::Part(_) => return false, // TODO: find this data in caniuse-lite
Component::Part(_) => Feature::PartPseudo,

Component::NonTSPseudoClass(pseudo) => {
match pseudo {
Expand Down

0 comments on commit fbf0d24

Please sign in to comment.