Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify comparison compat #54

Merged
merged 2 commits into from
Jan 15, 2022
Merged
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
8 changes: 4 additions & 4 deletions scripts/build-prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ for (let feature in mdnFeatures) {
} else {
version = feat.version_added;
}

if (!version) {
continue;
}
Expand Down Expand Up @@ -289,7 +289,7 @@ impl Feature {
if (!prefixMapping[prefix]) {
throw new Error('Missing prefix ' + prefix);
}
return `if version >= ${min} && version <= ${max} {
return `if ${min === max ? `version == ${min}` : `version >= ${min} && version <= ${max}`} {
prefixes |= VendorPrefix::${prefixMapping[prefix]};
}`
}).join('\n ')}
Expand Down Expand Up @@ -339,9 +339,9 @@ pub enum Feature {
impl Feature {
pub fn is_compatible(&self, browsers: Browsers) -> bool {
match self {
${[...compat].map(([features, browsers]) =>
${[...compat].map(([features, browsers]) =>
`${features.map(name => `Feature::${enumify(name)}`).join(' |\n ')} => {` + (Object.entries(browsers).length === 0 ? '}' : `
${Object.entries(browsers).map(([browser, min]) =>
${Object.entries(browsers).map(([browser, min]) =>
`if let Some(version) = browsers.${browser} {
if version >= ${min} {
return true
Expand Down
52 changes: 26 additions & 26 deletions src/prefixes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ impl Feature {
Feature::BorderBottomRightRadius |
Feature::BorderBottomLeftRadius => {
if let Some(version) = browsers.android {
if version >= 131328 && version <= 131328 {
if version == 131328 {
prefixes |= VendorPrefix::WebKit;
}
}
if let Some(version) = browsers.chrome {
if version >= 262144 && version <= 262144 {
if version == 262144 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand All @@ -214,7 +214,7 @@ impl Feature {
}
}
if let Some(version) = browsers.ios_saf {
if version >= 197120 && version <= 197120 {
if version == 197120 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand Down Expand Up @@ -282,7 +282,7 @@ impl Feature {
}
}
if let Some(version) = browsers.opera {
if version >= 786432 && version <= 786432 {
if version == 786432 {
prefixes |= VendorPrefix::O;
}
if version >= 983040 && version <= 1900544 {
Expand Down Expand Up @@ -349,7 +349,7 @@ impl Feature {
}
}
if let Some(version) = browsers.ie {
if version >= 589824 && version <= 589824 {
if version == 589824 {
prefixes |= VendorPrefix::Ms;
}
}
Expand Down Expand Up @@ -539,7 +539,7 @@ impl Feature {
}
}
if let Some(version) = browsers.safari {
if version >= 589824 && version <= 589824 {
if version == 589824 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand Down Expand Up @@ -609,7 +609,7 @@ impl Feature {
}
}
if let Some(version) = browsers.samsung {
if version >= 262144 && version <= 262144 {
if version == 262144 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand Down Expand Up @@ -643,7 +643,7 @@ impl Feature {
}
}
if let Some(version) = browsers.samsung {
if version >= 262144 && version <= 262144 {
if version == 262144 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand Down Expand Up @@ -725,7 +725,7 @@ impl Feature {
}
}
if let Some(version) = browsers.ie {
if version >= 655360 && version <= 655360 {
if version == 655360 {
prefixes |= VendorPrefix::Ms;
}
}
Expand Down Expand Up @@ -757,12 +757,12 @@ impl Feature {
}
}
if let Some(version) = browsers.ios_saf {
if version >= 393216 && version <= 393216 {
if version == 393216 {
prefixes |= VendorPrefix::WebKit;
}
}
if let Some(version) = browsers.safari {
if version >= 393216 && version <= 393216 {
if version == 393216 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand All @@ -775,12 +775,12 @@ impl Feature {
}
}
if let Some(version) = browsers.firefox {
if version >= 198144 && version <= 198144 {
if version == 198144 {
prefixes |= VendorPrefix::Moz;
}
}
if let Some(version) = browsers.opera {
if version >= 655360 && version <= 655360 {
if version == 655360 {
prefixes |= VendorPrefix::O;
}
}
Expand Down Expand Up @@ -849,14 +849,14 @@ impl Feature {
}
}
if let Some(version) = browsers.samsung {
if version >= 262144 && version <= 262144 {
if version == 262144 {
prefixes |= VendorPrefix::WebKit;
}
}
},
Feature::FontKerning => {
if let Some(version) = browsers.android {
if version >= 263168 && version <= 263168 {
if version == 263168 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand Down Expand Up @@ -1018,7 +1018,7 @@ impl Feature {
}
}
if let Some(version) = browsers.ie {
if version >= 720896 && version <= 720896 {
if version == 720896 {
prefixes |= VendorPrefix::Ms;
}
}
Expand Down Expand Up @@ -1067,10 +1067,10 @@ impl Feature {
}
}
if let Some(version) = browsers.edge {
if version >= 786432 && version <= 786432 {
if version == 786432 {
prefixes |= VendorPrefix::Ms;
}
if version >= 5767168 && version <= 5767168 {
if version == 5767168 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand Down Expand Up @@ -1185,7 +1185,7 @@ impl Feature {
}
}
if let Some(version) = browsers.samsung {
if version >= 262144 && version <= 262144 {
if version == 262144 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand Down Expand Up @@ -1266,7 +1266,7 @@ impl Feature {
}
}
if let Some(version) = browsers.samsung {
if version >= 262144 && version <= 262144 {
if version == 262144 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand Down Expand Up @@ -1331,7 +1331,7 @@ impl Feature {
},
Feature::TouchAction => {
if let Some(version) = browsers.ie {
if version >= 655360 && version <= 655360 {
if version == 655360 {
prefixes |= VendorPrefix::Ms;
}
}
Expand Down Expand Up @@ -1381,7 +1381,7 @@ impl Feature {
},
Feature::TextSizeAdjust => {
if let Some(version) = browsers.firefox {
if version >= 6029312 && version <= 6029312 {
if version == 6029312 {
prefixes |= VendorPrefix::Moz;
}
}
Expand Down Expand Up @@ -1622,7 +1622,7 @@ impl Feature {
}
}
if let Some(version) = browsers.safari {
if version >= 393216 && version <= 393216 {
if version == 393216 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand Down Expand Up @@ -1738,7 +1738,7 @@ impl Feature {
}
}
if let Some(version) = browsers.ie {
if version >= 720896 && version <= 720896 {
if version == 720896 {
prefixes |= VendorPrefix::Ms;
}
}
Expand Down Expand Up @@ -1887,7 +1887,7 @@ impl Feature {
}
}
if let Some(version) = browsers.samsung {
if version >= 262144 && version <= 262144 {
if version == 262144 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand Down Expand Up @@ -2098,7 +2098,7 @@ impl Feature {
},
Feature::ColorAdjust => {
if let Some(version) = browsers.android {
if version >= 6160384 && version <= 6160384 {
if version == 6160384 {
prefixes |= VendorPrefix::WebKit;
}
}
Expand Down