Skip to content

Commit fbf0d24

Browse files
committed
Add compat data for ::part
Fixes parcel-bundler#515
1 parent cff779d commit fbf0d24

File tree

4 files changed

+67
-2
lines changed

4 files changed

+67
-2
lines changed

scripts/build-prefixes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ let mdnFeatures = {
307307
}
308308
})
309309
),
310+
partPseudo: mdn.css.selectors.part.__compat.support,
310311
imageSet: mdn.css.types.image['image-set'].__compat.support,
311312
xResolutionUnit: mdn.css.types.resolution.x.__compat.support,
312313
nthChildOf: mdn.css.selectors['nth-child'].of_syntax.__compat.support,

src/compat.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ pub enum Feature {
122122
OriyaListStyleType,
123123
OverflowShorthand,
124124
P3Colors,
125+
PartPseudo,
125126
PersianListStyleType,
126127
PlaceContent,
127128
PlaceItems,
@@ -2500,6 +2501,51 @@ impl Feature {
25002501
return false;
25012502
}
25022503
}
2504+
Feature::PartPseudo => {
2505+
if let Some(version) = browsers.chrome {
2506+
if version < 4784128 {
2507+
return false;
2508+
}
2509+
}
2510+
if let Some(version) = browsers.edge {
2511+
if version < 5177344 {
2512+
return false;
2513+
}
2514+
}
2515+
if let Some(version) = browsers.firefox {
2516+
if version < 5177344 {
2517+
return false;
2518+
}
2519+
}
2520+
if let Some(version) = browsers.opera {
2521+
if version < 3407872 {
2522+
return false;
2523+
}
2524+
}
2525+
if let Some(version) = browsers.safari {
2526+
if version < 852224 {
2527+
return false;
2528+
}
2529+
}
2530+
if let Some(version) = browsers.ios_saf {
2531+
if version < 852992 {
2532+
return false;
2533+
}
2534+
}
2535+
if let Some(version) = browsers.samsung {
2536+
if version < 720896 {
2537+
return false;
2538+
}
2539+
}
2540+
if let Some(version) = browsers.android {
2541+
if version < 4784128 {
2542+
return false;
2543+
}
2544+
}
2545+
if browsers.ie.is_some() {
2546+
return false;
2547+
}
2548+
}
25032549
Feature::ImageSet => {
25042550
if let Some(version) = browsers.chrome {
25052551
if version < 1638400 {

src/lib.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9556,7 +9556,25 @@ mod tests {
95569556
Browsers {
95579557
safari: Some(12 << 16),
95589558
..Browsers::default()
9559-
}.into(),
9559+
}
9560+
.into(),
9561+
);
9562+
9563+
prefix_test(
9564+
r#"
9565+
.foo::part(header), .foo::part(body) {
9566+
display: none
9567+
}
9568+
"#,
9569+
indoc! {r#"
9570+
.foo::part(header), .foo::part(body) {
9571+
display: none;
9572+
}
9573+
"#},
9574+
Browsers {
9575+
safari: Some(14 << 16),
9576+
..Browsers::default()
9577+
},
95609578
);
95619579
}
95629580

src/selector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ pub(crate) fn is_compatible(selectors: &[Selector], targets: Targets) -> bool {
17461746

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

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

17511751
Component::NonTSPseudoClass(pseudo) => {
17521752
match pseudo {

0 commit comments

Comments
 (0)