Skip to content

Commit 08efeeb

Browse files
committed
separate compat data for -webkit-fill-available and -moz-available
fixes parcel-bundler#630
1 parent aedf6b6 commit 08efeeb

File tree

4 files changed

+69
-17
lines changed

4 files changed

+69
-17
lines changed

scripts/build-prefixes.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,13 @@ for (let key in mdn.css.properties['width']) {
382382
mdnFeatures[feat] = mdn.css.properties['width'][key].__compat.support;
383383
}
384384

385-
mdnFeatures.FillSize = Object.fromEntries(
386-
Object.entries(mdn.css.properties.width.stretch.__compat.support)
387-
.filter(([, v]) => v.alternative_name)
388-
.map(([k, v]) => [k, {version_added: v.version_added}])
389-
);
385+
Object.entries(mdn.css.properties.width.stretch.__compat.support)
386+
.filter(([, v]) => v.alternative_name)
387+
.forEach(([k, v]) => {
388+
let name = v.alternative_name.slice(1).replace(/[-_]([a-z])/g, (_, l) => l.toUpperCase()) + 'Size';
389+
mdnFeatures[name] ??= {};
390+
mdnFeatures[name][k] = {version_added: v.version_added};
391+
});
390392

391393
for (let feature in mdnFeatures) {
392394
let browserMap = {};

src/compat.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ pub enum Feature {
6262
EthiopicNumericListStyleType,
6363
ExUnit,
6464
ExtendedSystemFonts,
65-
FillSize,
6665
FirstLetter,
6766
FirstLine,
6867
FitContentFunctionSize,
@@ -135,6 +134,7 @@ pub enum Feature {
135134
MinFunction,
136135
ModFunction,
137136
MongolianListStyleType,
137+
MozAvailableSize,
138138
MyanmarListStyleType,
139139
Namespaces,
140140
Nesting,
@@ -206,6 +206,7 @@ pub enum Feature {
206206
VmaxUnit,
207207
VminUnit,
208208
VwUnit,
209+
WebkitFillAvailableSize,
209210
XResolutionUnit,
210211
}
211212

@@ -4801,7 +4802,7 @@ impl Feature {
48014802
return false;
48024803
}
48034804
}
4804-
Feature::FillSize => {
4805+
Feature::WebkitFillAvailableSize => {
48054806
if let Some(version) = browsers.chrome {
48064807
if version < 1638400 {
48074808
return false;
@@ -4812,11 +4813,6 @@ impl Feature {
48124813
return false;
48134814
}
48144815
}
4815-
if let Some(version) = browsers.firefox {
4816-
if version < 262144 {
4817-
return false;
4818-
}
4819-
}
48204816
if let Some(version) = browsers.opera {
48214817
if version < 917504 {
48224818
return false;
@@ -4842,7 +4838,25 @@ impl Feature {
48424838
return false;
48434839
}
48444840
}
4845-
if browsers.ie.is_some() {
4841+
if browsers.firefox.is_some() || browsers.ie.is_some() {
4842+
return false;
4843+
}
4844+
}
4845+
Feature::MozAvailableSize => {
4846+
if let Some(version) = browsers.firefox {
4847+
if version < 262144 {
4848+
return false;
4849+
}
4850+
}
4851+
if browsers.android.is_some()
4852+
|| browsers.chrome.is_some()
4853+
|| browsers.edge.is_some()
4854+
|| browsers.ie.is_some()
4855+
|| browsers.ios_saf.is_some()
4856+
|| browsers.opera.is_some()
4857+
|| browsers.safari.is_some()
4858+
|| browsers.samsung.is_some()
4859+
{
48464860
return false;
48474861
}
48484862
}

src/lib.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,6 +3767,32 @@ mod tests {
37673767
},
37683768
);
37693769

3770+
prefix_test(
3771+
&format!(
3772+
r#"
3773+
.foo {{
3774+
{}: 100vw;
3775+
{}: -webkit-fill-available;
3776+
}}
3777+
"#,
3778+
in_prop, in_prop
3779+
),
3780+
&format!(
3781+
indoc! {r#"
3782+
.foo {{
3783+
{}: 100vw;
3784+
{}: -webkit-fill-available;
3785+
}}
3786+
"#},
3787+
out_prop, out_prop
3788+
),
3789+
Browsers {
3790+
safari: Some(8 << 16),
3791+
firefox: Some(4 << 16),
3792+
..Browsers::default()
3793+
},
3794+
);
3795+
37703796
prefix_test(
37713797
&format!(
37723798
r#"

src/properties/size.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,13 @@ impl IsCompatible for Size {
142142
FitContentFunction(l) => {
143143
Feature::FitContentFunctionSize.is_compatible(browsers) && l.is_compatible(browsers)
144144
}
145-
Stretch(vp) if *vp == VendorPrefix::None => Feature::StretchSize.is_compatible(browsers),
146-
Stretch(..) => Feature::FillSize.is_compatible(browsers),
145+
Stretch(vp) => match *vp {
146+
VendorPrefix::None => Feature::StretchSize,
147+
VendorPrefix::WebKit => Feature::WebkitFillAvailableSize,
148+
VendorPrefix::Moz => Feature::MozAvailableSize,
149+
_ => return false,
150+
}
151+
.is_compatible(browsers),
147152
Contain => false, // ??? no data in mdn
148153
Auto => true,
149154
}
@@ -271,8 +276,13 @@ impl IsCompatible for MaxSize {
271276
FitContentFunction(l) => {
272277
Feature::FitContentFunctionSize.is_compatible(browsers) && l.is_compatible(browsers)
273278
}
274-
Stretch(vp) if *vp == VendorPrefix::None => Feature::StretchSize.is_compatible(browsers),
275-
Stretch(..) => Feature::FillSize.is_compatible(browsers),
279+
Stretch(vp) => match *vp {
280+
VendorPrefix::None => Feature::StretchSize,
281+
VendorPrefix::WebKit => Feature::WebkitFillAvailableSize,
282+
VendorPrefix::Moz => Feature::MozAvailableSize,
283+
_ => return false,
284+
}
285+
.is_compatible(browsers),
276286
Contain => false, // ??? no data in mdn
277287
None => true,
278288
}

0 commit comments

Comments
 (0)