Skip to content

Commit dac7399

Browse files
authored
Upgrade: Bump @mdn/browser-compat-data from 4.1.10 to 5.5.23
Updates mdn-data to latest version 2.6.1 and @mdn/browser-compat-data to 5.5.23. It also updates the test and dependencies to be able to work with this latest update. --- Close #5834 Close #5824
1 parent b79ae9b commit dac7399

File tree

16 files changed

+86
-62
lines changed

16 files changed

+86
-62
lines changed

packages/extension-browser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"workerThreads": false
1111
},
1212
"browserslist": "last 2 chrome versions, last 2 firefox versions",
13-
"bundleSize": 810000,
13+
"bundleSize": 1880000,
1414
"description": "webhint browser extension",
1515
"devDependencies": {
1616
"@hint/hint-axe": "^4.4.20",

packages/hint-compat-api/tests/css.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ testHint(hintPath,
9494
link: 'https://developer.mozilla.org/docs/Web/CSS/appearance',
9595
text: 'Learn more about this CSS feature on MDN'
9696
}],
97-
message: `'appearance' is not supported by Chrome < 84, Edge < 84, Firefox < 80, Internet Explorer. Add '-webkit-appearance' to support Chrome, Edge 12+. Add '-moz-appearance' to support Firefox.`,
97+
message: `'appearance' is not supported by Chrome < 84, Edge < 84, Firefox < 80, Internet Explorer. Add '-webkit-appearance' to support Chrome, Edge 12+, Firefox 64+. Add '-moz-appearance' to support Firefox.`,
9898
position: { match: 'appearance: button; /* Report 6 */', range: 'appearance' },
9999
severity: Severity.error
100100
}
@@ -243,7 +243,7 @@ testHint(hintPath,
243243
link: 'https://developer.mozilla.org/docs/Web/CSS/CSS_Grid_Layout/Subgrid',
244244
text: 'Learn more about this CSS feature on MDN'
245245
}],
246-
message: `'grid-template-rows: subgrid' is not supported by Edge.`,
246+
message: `'grid-template-rows: subgrid' is not supported by Edge < 117.`,
247247
position: { match: 'subgrid;', range: 'subgrid' },
248248
severity: Severity.warning
249249
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<blink></blink>
1+
<search title="Sample Title">...</search>
22
<details></details>
33
<div></div>

packages/hint-compat-api/tests/html.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ testHint(hintPath,
4545
reports: [
4646
{
4747
documentation: [{
48-
link: 'https://developer.mozilla.org/docs/Web/HTML/Element/blink',
48+
link: 'https://developer.mozilla.org/docs/Web/HTML/Element/search',
4949
text: 'Learn more about this HTML feature on MDN'
5050
}],
51-
message: `'blink' is not supported by Chrome, Edge, Firefox 22+, Internet Explorer.`,
52-
position: { match: 'blink' },
51+
message: `'search' is not supported by Chrome < 118, Edge < 118, Firefox < 118, Internet Explorer.`,
52+
position: { match: 'search' },
5353
severity: Severity.warning
5454
},
5555
{

packages/utils-compat-data/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
},
1111
"dependencies": {
1212
"@hint/utils-css": "^1.0.15",
13-
"@mdn/browser-compat-data": "^4.1.10",
14-
"mdn-data": "^2.0.27",
13+
"@mdn/browser-compat-data": "^5.5.23",
14+
"mdn-data": "^2.6.1",
1515
"postcss-selector-parser": "^6.0.8",
1616
"postcss-value-parser": "^4.2.0",
1717
"semver": "^7.3.5"

packages/utils-compat-data/scripts/extra-data.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ const extraData = {
3131
}
3232
}
3333
}
34-
}
34+
},
3535
},
3636
types: {
3737
color: {
38-
alpha_hexadecimal_notation: {
39-
__compat: {
40-
match: {
41-
regex_token: '^#[0-9a-fA-F]{4}(?:[0-9a-fA-F]{4})?$'
38+
rgb_hexadecimal_notation: {
39+
alpha_hexadecimal_notation: {
40+
__compat: {
41+
match: {
42+
regex_token: '^#[0-9a-fA-F]{4}(?:[0-9a-fA-F]{4})?$'
43+
}
4244
}
4345
}
4446
}

packages/utils-compat-data/scripts/mdn-browser-compat-data.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ const removeFeatureData = (data) => {
213213
delete compat.description;
214214
// Status is not needed for analysis.
215215
delete data.__compat.status;
216+
// Source file is not needed for analysis
217+
delete data.__compat.source_file;
218+
// Tags not needed for analysis
219+
delete data.__compat.tags;
220+
// delete non-desktop or mobile browser to reduce size of bundle.
221+
delete support.oculus;
222+
// Spec url is not needed for analysis.
223+
delete data.__compat.spec_url;
216224

217225
// Remove unnecessary data per-browser.
218226
for (const browserName of Object.keys(support)) {
@@ -280,12 +288,12 @@ removeFeatures(data.css);
280288
removeFeatures(data.html);
281289

282290
const code = `/* eslint-disable */
283-
import { Browsers, PrimaryIdentifier } from '@mdn/browser-compat-data/types';
291+
import { Browsers, Identifier, CompatStatement } from '@mdn/browser-compat-data/types';
284292
285293
type Data = {
286294
browsers: Browsers;
287-
css: PrimaryIdentifier;
288-
html: PrimaryIdentifier;
295+
css: Identifier & {__compat?: CompatStatement};
296+
html: Identifier & {__compat?: CompatStatement};
289297
}
290298
291299
export const mdn: Data = ${JSON.stringify(data, null, 4)} as any;

packages/utils-compat-data/scripts/mdn-data.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const propertyRef = /<'([a-z-]+)'>/gi;
1414
/** Match a reference to a CSS type, e.g. `<color>` */
1515
const typeRef = /<([a-z-]+)>/gi;
1616

17+
const problematicIds = new Set([
18+
'white-space-trim' // not present in mdn-data/css/properties.json
19+
]);
20+
1721
/**
1822
* Helper for `[].flatMap` until we move to Node 11+.
1923
* @param {any[]} arr
@@ -48,11 +52,15 @@ const matchAll = (str, regex) => {
4852
* @returns {string[]} A flattened array of all referenced types.
4953
*/
5054
const getTypesForProperty = (name) => {
55+
if (problematicIds.has(name)){
56+
return [name, ''];
57+
}
58+
5159
const { syntax } = properties[name];
5260
const typeRefs = [...matchAll(syntax, typeRef)].map((m) => {
5361
return m[1];
5462
});
55-
/** @type {string[]} */
63+
/** @type {string[]} */
5664
const propertyRefs = flatMap([...matchAll(syntax, propertyRef)], (m) => {
5765
return getTypesForProperty(m[1]);
5866
});

packages/utils-compat-data/src/browsers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Identifier, SimpleSupportStatement, SupportStatement } from '@mdn/browser-compat-data/types';
1+
import { BrowserName, CompatStatement, Identifier, SimpleSupportStatement, SupportStatement } from '@mdn/browser-compat-data/types';
22
const semver = require('semver/preload');
33

44
import { mdn } from './browser-compat-data';
@@ -55,7 +55,7 @@ const coerce = (version: string): string | import('semver').SemVer => {
5555
};
5656

5757
const normalizeBrowserName = (name: string) => {
58-
return browserToMDN.get(name) || name;
58+
return (browserToMDN.get(name) || name) as BrowserName;
5959
};
6060

6161
/**
@@ -204,7 +204,7 @@ export const getFriendlyName = (browser: string): string => {
204204
* @param feature An MDN feature `Identifier` with `__compat` data.
205205
* @param browsers A list of target browsers (e.g. `['chrome 74', 'ie 11']`).
206206
*/
207-
export const getUnsupportedBrowsers = (feature: Identifier | undefined, prefix: string, browsers: string[], unprefixed: string, parent?: Identifier): UnsupportedBrowsers | null => {
207+
export const getUnsupportedBrowsers = (feature: (Identifier & {__compat?: CompatStatement}) | undefined, prefix: string, browsers: string[], unprefixed: string, parent?: Identifier & {__compat?: CompatStatement}): UnsupportedBrowsers | null => {
208208
if (!feature || !feature.__compat || !feature.__compat.support) {
209209
return null; // Assume support if no matching feature was provided.
210210
}

packages/utils-compat-data/src/css.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Identifier } from '@mdn/browser-compat-data/types';
1+
import { CompatStatement, Identifier } from '@mdn/browser-compat-data/types';
22
import { getUnprefixed, getVendorPrefix } from '@hint/utils-css';
33

44
import { mdn } from './browser-compat-data';
@@ -60,9 +60,14 @@ const getTokens = (nodes: any[]): [string, string][] => {
6060
* Check if any parts of a value align with an MDN feature's matches clause.
6161
* If so, return browser support based on that feature's data.
6262
*/
63-
const getValueMatchesUnsupported = (context: Identifier, featureSupport: Identifier, value: ParsedValue, browsers: string[]): UnsupportedBrowsers | null => {
63+
const getValueMatchesUnsupported = (context: Identifier & {__compat?: CompatStatement}, featureSupport: Identifier & {__compat?: CompatStatement}, value: ParsedValue, browsers: string[]): UnsupportedBrowsers | null => {
6464
const { prefix, tokens, unprefixedValue } = value;
65-
const matches = featureSupport.__compat && (featureSupport.__compat as IMatchesCompatStatement).matches;
65+
let matches = featureSupport.__compat && (featureSupport.__compat as IMatchesCompatStatement).matches;
66+
67+
// Matches Block property could be available either as matches or match.
68+
if (!matches) {
69+
matches = featureSupport.__compat && (featureSupport.__compat as IMatchesCompatStatement).match;
70+
}
6671

6772
if (!matches) {
6873
return null;
@@ -97,7 +102,7 @@ const getValueMatchesUnsupported = (context: Identifier, featureSupport: Identif
97102
* Check if any parts of a value align with an MDN feature's name.
98103
* If so, return browser support based on that feature's data.
99104
*/
100-
const getValueTokenUnsupported = (context: Identifier, featureName: string, featureSupport: Identifier, value: ParsedValue, browsers: string[]): UnsupportedBrowsers | null => {
105+
const getValueTokenUnsupported = (context: Identifier & {__compat?: CompatStatement}, featureName: string, featureSupport: Identifier & {__compat?: CompatStatement}, value: ParsedValue, browsers: string[]): UnsupportedBrowsers | null => {
101106
for (const [tokenPrefix, tokenValue] of value.tokens) {
102107
if (featureName === tokenValue) {
103108
return getUnsupportedBrowsers(featureSupport, tokenPrefix, browsers, tokenValue, context);
@@ -112,15 +117,15 @@ const getValueTokenUnsupported = (context: Identifier, featureName: string, feat
112117
* sub-features in the provided context, using keys and `matches` data
113118
* to test each tokenized string from the value.
114119
*/
115-
const getPartialValueUnsupported = (context: Identifier, value: ParsedValue, browsers: string[]): UnsupportedBrowsers | null => {
120+
const getPartialValueUnsupported = (context: Identifier & {__compat?: CompatStatement}, value: ParsedValue, browsers: string[]): UnsupportedBrowsers | null => {
116121
for (const [featureName, featureSupport] of Object.entries(context)) {
117122
if (featureName === '__compat') {
118123
continue;
119124
}
120125

121-
const unsupported = getValueMatchesUnsupported(context, featureSupport, value, browsers) ||
122-
getValueTokenUnsupported(context, featureName, featureSupport, value, browsers) ||
123-
getPartialValueUnsupported(featureSupport, value, browsers);
126+
const unsupported = getValueMatchesUnsupported(context, featureSupport as Identifier & {__compat?: CompatStatement}, value, browsers) ||
127+
getValueTokenUnsupported(context, featureName, featureSupport as Identifier & {__compat?: CompatStatement}, value, browsers) ||
128+
getPartialValueUnsupported(featureSupport as Identifier & {__compat?: CompatStatement}, value, browsers);
124129

125130
if (unsupported) {
126131
return unsupported;
@@ -138,11 +143,11 @@ const getPartialValueUnsupported = (context: Identifier, value: ParsedValue, bro
138143
* (to reduce bundle size), but referenced CSS types with partial support may
139144
* still exist (e.g. "color" and alpha_hex_value).
140145
*/
141-
const getValueUnsupported = (context: Identifier | undefined, property: string, value: string, browsers: string[]): UnsupportedBrowsers | null => {
146+
const getValueUnsupported = (context: (Identifier & {__compat?: CompatStatement}) | undefined, property: string, value: string, browsers: string[]): UnsupportedBrowsers | null => {
142147
const [data, prefix, unprefixedValue] = getFeatureData(context, value);
143148

144149
if (data) {
145-
return getUnsupportedBrowsers(data, prefix, browsers, unprefixedValue, data.__compat?.mdn_url ? undefined : context);
150+
return getUnsupportedBrowsers(data as (Identifier & {__compat?: CompatStatement}), prefix, browsers, unprefixedValue, (data as (Identifier & {__compat?: CompatStatement})).__compat?.mdn_url ? undefined : context);
146151
}
147152

148153
const parsedValue: ParsedValue = {
@@ -154,7 +159,7 @@ const getValueUnsupported = (context: Identifier | undefined, property: string,
154159
// Check browser support for each CSS type associated with the property (if any).
155160
if (types.has(property)) {
156161
for (const type of types.get(property)!) {
157-
const typeContext = mdn.css.types[type];
162+
const typeContext: Identifier & {__compat?: CompatStatement} = mdn.css.types[type] as (Identifier & {__compat?: CompatStatement});
158163
const result = typeContext && getPartialValueUnsupported(typeContext, parsedValue, browsers);
159164

160165
if (result) {
@@ -174,13 +179,13 @@ export const getDeclarationUnsupported = (feature: DeclarationQuery, browsers: s
174179
const key = `css-declaration:${feature.property}|${feature.value || ''}`;
175180

176181
return getCachedValue(key, browsers, () => {
177-
const [data, prefix, unprefixed] = getFeatureData(mdn.css.properties, feature.property);
182+
const [data, prefix, unprefixed] = getFeatureData(mdn.css.properties as (Identifier & {__compat?: CompatStatement}), feature.property);
178183

179184
if (feature.value) {
180-
return getValueUnsupported(data, unprefixed, feature.value, browsers);
185+
return getValueUnsupported(data as (Identifier & {__compat?: CompatStatement}), unprefixed, feature.value, browsers);
181186
}
182187

183-
return getUnsupportedBrowsers(data, prefix, browsers, unprefixed);
188+
return getUnsupportedBrowsers(data as (Identifier & {__compat?: CompatStatement}), prefix, browsers, unprefixed);
184189
});
185190
};
186191

@@ -189,19 +194,19 @@ export const getDeclarationUnsupported = (feature: DeclarationQuery, browsers: s
189194
*/
190195
export const getRuleUnsupported = (feature: RuleQuery, browsers: string[]): UnsupportedBrowsers | null => {
191196
return getCachedValue(`css-rule:${feature.rule}`, browsers, () => {
192-
const [data, prefix, unprefixed] = getFeatureData(mdn.css['at-rules'], feature.rule);
197+
const [data, prefix, unprefixed] = getFeatureData(mdn.css['at-rules'] as (Identifier & {__compat?: CompatStatement}), feature.rule);
193198

194-
return getUnsupportedBrowsers(data, prefix, browsers, unprefixed);
199+
return getUnsupportedBrowsers(data as (Identifier & {__compat?: CompatStatement}), prefix, browsers, unprefixed);
195200
});
196201
};
197202

198203
const getPseudoSelectorUnsupported = (value: string, browsers: string[]): UnsupportedBrowsers | null => {
199204
const name = value.replace(/^::?/, ''); // Strip leading `:` or `::`.
200205

201206
return getCachedValue(`css-pseudo-selector:${name}`, browsers, () => {
202-
const [data, prefix, unprefixed] = getFeatureData(mdn.css.selectors, name);
207+
const [data, prefix, unprefixed] = getFeatureData(mdn.css.selectors as (Identifier & {__compat?: CompatStatement}), name);
203208

204-
return getUnsupportedBrowsers(data, prefix, browsers, unprefixed);
209+
return getUnsupportedBrowsers(data as (Identifier & {__compat?: CompatStatement}), prefix, browsers, unprefixed);
205210
});
206211
};
207212

0 commit comments

Comments
 (0)