From a52b34f7d63c08adbef1eda96e3cb8121a4c7b65 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Thu, 27 Aug 2020 16:54:10 -0700 Subject: [PATCH 01/55] Mirroring script: Edge mirrors from both IE AND Chrome at the same time --- docs/contributing.md | 24 ++++----- scripts/mirror.js | 113 +++++++++++++++++++------------------------ 2 files changed, 63 insertions(+), 74 deletions(-) diff --git a/docs/contributing.md b/docs/contributing.md index bc1fd0d23c878f..e08d99dfa26d55 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -74,18 +74,18 @@ If the feature you're interested in is a JavaScript API, you can cross-reference Many browsers within BCD can be derived from other browsers given they share the same engine, for example Opera derives from Chrome, and Firefox Android derives from Firefox. To help cut down time working on copying values between browsers, a mirroring script is provided. You can run `npm run mirror [--source=""] [--modify=""]` to automatically copy values. -The argument is the destination browser that values will be copied to. The script automatically determines what browser to copy from based upon the destination (see table below), but manual specification is possible through the `--source=""` argument. - -| Destination | Default Source | -| ---------------- | ----------------- | -| Chrome Android | Chrome | -| Edge | Internet Explorer | -| Firefox Android | Firefox | -| Opera | Chrome | -| Opera Android | Chrome Android | -| Safari iOS | Safari | -| Samsung Internet | Chrome Android | -| WebView | Chrome Android | +The argument is the destination browser that values will be copied to. The script automatically determines what browser to copy from based upon the destination (see table below), but manual specification is possible through the `--source=""` argument. (Mirroring data for Edge ignores this argument.) + +| Destination | Default Source | +| ---------------- | -------------------------- | +| Chrome Android | Chrome | +| Edge | Internet Explorer + Chrome | +| Firefox Android | Firefox | +| Opera | Chrome | +| Opera Android | Chrome Android | +| Safari iOS | Safari | +| Samsung Internet | Chrome Android | +| WebView | Chrome Android | The argument is either the identifier of the feature to update (i.e. `css.at-rules.namespace`), a filename (`javascript/operators/arithmetic.json`), or an entire folder (`api`). diff --git a/scripts/mirror.js b/scripts/mirror.js index eb004f19881af6..3b80534216e3e7 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -219,71 +219,61 @@ const bumpChromeAndroid = (originalData, sourceData, source) => { }; /** - * @param {SupportStatement} originalData - * @param {SupportStatement} sourceData - * @param {string} source + * @param {SupportStatement} comp * @returns {SupportStatement} */ -const bumpEdge = (originalData, sourceData, source) => { - let newData = {}; - - if (source == 'ie') { - if (sourceData.version_removed && sourceData.version_removed !== null) { - newData.version_added = false; - } else if (sourceData.version_added !== null) { - newData.version_added = sourceData.version_added ? '12' : null; - } +const bumpEdge = comp => { + let newData = comp['edge']; + let originalData = comp['edge']; + let ieData = comp['ie']; + let chromeData = comp['chrome']; - if (sourceData.notes) { - newData.notes = updateNotes( - sourceData.notes, - /Internet Explorer/g, - 'Edge', - ); - } - } else if (source == 'chrome') { - newData = originalData == undefined ? sourceData : originalData; + if (ieData.version_removed && ieData.version_removed !== null) { + newData.version_added = false; + } else if (ieData.version_added !== null) { + newData.version_added = ieData.version_added ? '12' : null; + } - let chromeFalse = - sourceData.version_added === false || - sourceData.version_removed !== undefined; - let chromeNull = sourceData.version_added === null; + let chromeFalse = + chromeData.version_added === false || + chromeData.version_removed !== undefined; + let chromeNull = chromeData.version_added === null; - if (originalData === undefined) { - newData.version_added = chromeFalse ? false : chromeNull ? null : '≤79'; - } else { - if (!chromeFalse && !chromeNull) { - if (originalData.version_added == true) { - newData.version_added = '≤18'; - } else { - if ( - sourceData.version_added == true || - Number(sourceData.version_added) <= 79 - ) { - if (originalData.version_added == false) { - newData.version_added = '79'; - } else if (originalData.version_added == null) { - newData.version_added = '≤79'; - } - } else { - newData.version_added == sourceData.version_added; + if (originalData === undefined) { + newData.version_added = chromeFalse ? false : chromeNull ? null : '≤79'; + } else { + if (!chromeFalse && !chromeNull) { + if (originalData.version_added == true) { + newData.version_added = '≤18'; + } else { + if ( + chromeData.version_added == true || + Number(chromeData.version_added) <= 79 + ) { + if (originalData.version_added == false) { + newData.version_added = '79'; + } else if (originalData.version_added == null) { + newData.version_added = '≤79'; } + } else { + newData.version_added == chromeData.version_added; } - } else if (chromeFalse) { - if (originalData.version_added && !originalData.version_removed) { - newData.version_removed = '79'; - } + } + } else if (chromeFalse) { + if (originalData.version_added && !originalData.version_removed) { + newData.version_removed = '79'; } } + } - let newNotes = combineNotes( - updateNotes(sourceData.notes, /Chrome/g, 'Edge'), - originalData.notes, - ); + let newNotes = combineNotes( + updateNotes(ieData.notes, /Internet Explorer/g, 'Edge'), + updateNotes(chromeData.notes, /Chrome/g, 'Edge'), + originalData.notes, + ); - if (newNotes) { - newData.notes = newNotes; - } + if (newNotes) { + newData.notes = newNotes; } return newData; @@ -512,10 +502,7 @@ const bumpVersion = (data, destination, source, originalData) => { let newData = null; if (data == null) { return null; - } else if ( - Array.isArray(data) && - !(destination == 'edge' && source == 'chrome') - ) { + } else if (Array.isArray(data)) { newData = []; for (let i = 0; i < data.length; i++) { newData[i] = bumpVersion(data[i], destination, source, originalData); @@ -527,9 +514,6 @@ const bumpVersion = (data, destination, source, originalData) => { case 'chrome_android': bumpFunction = bumpChromeAndroid; break; - case 'edge': - bumpFunction = bumpEdge; - break; case 'firefox_android': bumpFunction = bumpFirefoxAndroid; break; @@ -594,7 +578,12 @@ const doSetFeature = (data, newData, rootPath, browser, source, modify) => { } if (doBump) { - let newValue = bumpVersion(comp[source], browser, source, comp[browser]); + let newValue = null; + if (browser == 'edge') { + newValue = bumpEdge(comp); + } else { + newValue = bumpVersion(comp[source], browser, source, comp[browser]); + } if (newValue !== null) { newData[rootPath].__compat.support[browser] = newValue; } From d7506caf825c9bf1a49481e366ebafb0f3651207 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Fri, 28 Aug 2020 04:33:23 -0700 Subject: [PATCH 02/55] Update scripts/mirror.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Philip Jägenstedt --- scripts/mirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 3b80534216e3e7..3fee3d9b09a404 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -228,7 +228,7 @@ const bumpEdge = comp => { let ieData = comp['ie']; let chromeData = comp['chrome']; - if (ieData.version_removed && ieData.version_removed !== null) { + if (ieData.version_removed !== null) { newData.version_added = false; } else if (ieData.version_added !== null) { newData.version_added = ieData.version_added ? '12' : null; From 107de7a0512cf0538aff85e1d10663ff75a0824c Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Fri, 28 Aug 2020 04:36:03 -0700 Subject: [PATCH 03/55] Check if IE data exists --- scripts/mirror.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 3fee3d9b09a404..48eb29f3643a47 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -228,10 +228,12 @@ const bumpEdge = comp => { let ieData = comp['ie']; let chromeData = comp['chrome']; - if (ieData.version_removed !== null) { - newData.version_added = false; - } else if (ieData.version_added !== null) { - newData.version_added = ieData.version_added ? '12' : null; + if (ieData) { + if (ieData.version_removed !== null) { + newData.version_added = false; + } else if (ieData.version_added !== null) { + newData.version_added = ieData.version_added ? '12' : null; + } } let chromeFalse = From 634f0da9567ae651bfb62a8e2268891fd681a960 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Fri, 28 Aug 2020 04:51:37 -0700 Subject: [PATCH 04/55] Initialize newData as copy of originalData --- scripts/mirror.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 48eb29f3643a47..253b4e9877977a 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -223,7 +223,7 @@ const bumpChromeAndroid = (originalData, sourceData, source) => { * @returns {SupportStatement} */ const bumpEdge = comp => { - let newData = comp['edge']; + let newData = copyStatement(comp['edge']); let originalData = comp['edge']; let ieData = comp['ie']; let chromeData = comp['chrome']; @@ -258,13 +258,15 @@ const bumpEdge = comp => { newData.version_added = '≤79'; } } else { - newData.version_added == chromeData.version_added; + newData.version_added = chromeData.version_added; } } } else if (chromeFalse) { if (originalData.version_added && !originalData.version_removed) { newData.version_removed = '79'; } + } else if (chromeNull) { + newData.version_added = null; } } From b039956a3b441e74f6fa7c84c26883323a0b5fff Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Fri, 28 Aug 2020 04:59:40 -0700 Subject: [PATCH 05/55] Rename comp to compData --- scripts/mirror.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 253b4e9877977a..bd30c67870b497 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -219,14 +219,14 @@ const bumpChromeAndroid = (originalData, sourceData, source) => { }; /** - * @param {SupportStatement} comp + * @param {SupportStatement} compData * @returns {SupportStatement} */ -const bumpEdge = comp => { - let newData = copyStatement(comp['edge']); - let originalData = comp['edge']; - let ieData = comp['ie']; - let chromeData = comp['chrome']; +const bumpEdge = compData => { + let newData = copyStatement(compData['edge']); + let originalData = compData['edge']; + let ieData = compData['ie']; + let chromeData = compData['chrome']; if (ieData) { if (ieData.version_removed !== null) { @@ -557,7 +557,7 @@ const bumpVersion = (data, destination, source, originalData) => { @ @returns {Identifier} */ const doSetFeature = (data, newData, rootPath, browser, source, modify) => { - let comp = data[rootPath].__compat.support; + let compData = data[rootPath].__compat.support; let doBump = false; if (modify == 'always') { @@ -567,15 +567,15 @@ const doSetFeature = (data, newData, rootPath, browser, source, modify) => { modify == 'nonreal' ? [true, null, undefined] : [true, false, null, undefined]; - if (Array.isArray(comp[browser])) { - for (let i = 0; i < comp[browser].length; i++) { - if (triggers.includes(comp[browser][i].version_added)) { + if (Array.isArray(compData[browser])) { + for (let i = 0; i < compData[browser].length; i++) { + if (triggers.includes(compData[browser][i].version_added)) { doBump = true; break; } } - } else if (comp[browser] !== undefined) { - doBump = triggers.includes(comp[browser].version_added); + } else if (compData[browser] !== undefined) { + doBump = triggers.includes(compData[browser].version_added); } else { doBump = true; } @@ -584,9 +584,14 @@ const doSetFeature = (data, newData, rootPath, browser, source, modify) => { if (doBump) { let newValue = null; if (browser == 'edge') { - newValue = bumpEdge(comp); + newValue = bumpEdge(compData); } else { - newValue = bumpVersion(comp[source], browser, source, comp[browser]); + newValue = bumpVersion( + compData[source], + browser, + source, + compData[browser], + ); } if (newValue !== null) { newData[rootPath].__compat.support[browser] = newValue; From 3c8be75fb9d3016a4d0f528a57dda7a86249f050 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Fri, 28 Aug 2020 05:07:01 -0700 Subject: [PATCH 06/55] Check if IE data exists in notes --- scripts/mirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index bd30c67870b497..1bd03ceef07790 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -271,7 +271,7 @@ const bumpEdge = compData => { } let newNotes = combineNotes( - updateNotes(ieData.notes, /Internet Explorer/g, 'Edge'), + ieData ? updateNotes(ieData.notes, /Internet Explorer/g, 'Edge') : null, updateNotes(chromeData.notes, /Chrome/g, 'Edge'), originalData.notes, ); From 878ab38c6920aa11c2b69aaf0520cf30a7b15795 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Fri, 28 Aug 2020 05:12:00 -0700 Subject: [PATCH 07/55] Remove redundant if clause --- scripts/mirror.js | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 1bd03ceef07790..709b670e5d05b2 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -241,33 +241,29 @@ const bumpEdge = compData => { chromeData.version_removed !== undefined; let chromeNull = chromeData.version_added === null; - if (originalData === undefined) { - newData.version_added = chromeFalse ? false : chromeNull ? null : '≤79'; - } else { - if (!chromeFalse && !chromeNull) { - if (originalData.version_added == true) { - newData.version_added = '≤18'; - } else { - if ( - chromeData.version_added == true || - Number(chromeData.version_added) <= 79 - ) { - if (originalData.version_added == false) { - newData.version_added = '79'; - } else if (originalData.version_added == null) { - newData.version_added = '≤79'; - } - } else { - newData.version_added = chromeData.version_added; + if (!chromeFalse && !chromeNull) { + if (originalData.version_added == true) { + newData.version_added = '≤18'; + } else { + if ( + chromeData.version_added == true || + Number(chromeData.version_added) <= 79 + ) { + if (originalData.version_added == false) { + newData.version_added = '79'; + } else if (originalData.version_added == null) { + newData.version_added = '≤79'; } + } else { + newData.version_added = chromeData.version_added; } - } else if (chromeFalse) { - if (originalData.version_added && !originalData.version_removed) { - newData.version_removed = '79'; - } - } else if (chromeNull) { - newData.version_added = null; } + } else if (chromeFalse) { + if (originalData.version_added && !originalData.version_removed) { + newData.version_removed = '79'; + } + } else if (chromeNull) { + newData.version_added = null; } let newNotes = combineNotes( From ee436aa3dfb574be3e04ffd33e87241fd79f0735 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Fri, 28 Aug 2020 05:25:15 -0700 Subject: [PATCH 08/55] De-special case Edge mirroring --- scripts/mirror.js | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 709b670e5d05b2..bfc941f775df32 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -220,13 +220,12 @@ const bumpChromeAndroid = (originalData, sourceData, source) => { /** * @param {SupportStatement} compData + * @param {SupportStatement} chromeData + * @param {SupportStatement} ieData * @returns {SupportStatement} */ -const bumpEdge = compData => { - let newData = copyStatement(compData['edge']); - let originalData = compData['edge']; - let ieData = compData['ie']; - let chromeData = compData['chrome']; +const bumpEdge = (originalData, chromeData, ieData) => { + let newData = copyStatement(originalData); if (ieData) { if (ieData.version_removed !== null) { @@ -497,15 +496,22 @@ const bumpGeneric = (originalData, sourceData, source) => { * @param {string} destination * @param {string} source * @param {SupportStatement} originalData + * @param {SupportStatement} compData */ -const bumpVersion = (data, destination, source, originalData) => { +const bumpVersion = (data, destination, source, originalData, compData) => { let newData = null; if (data == null) { return null; } else if (Array.isArray(data)) { newData = []; for (let i = 0; i < data.length; i++) { - newData[i] = bumpVersion(data[i], destination, source, originalData); + newData[i] = bumpVersion( + data[i], + destination, + source, + originalData, + compData, + ); } } else { let bumpFunction = null; @@ -517,6 +523,9 @@ const bumpVersion = (data, destination, source, originalData) => { case 'firefox_android': bumpFunction = bumpFirefoxAndroid; break; + case 'edge': + bumpFunction = (originalData, data, source) => + bumpEdge(originalData, data, compData['ie']); case 'opera': bumpFunction = bumpOpera; break; @@ -578,17 +587,12 @@ const doSetFeature = (data, newData, rootPath, browser, source, modify) => { } if (doBump) { - let newValue = null; - if (browser == 'edge') { - newValue = bumpEdge(compData); - } else { - newValue = bumpVersion( - compData[source], - browser, - source, - compData[browser], - ); - } + let newValue = bumpVersion( + compData[source], + browser, + source, + compData[browser], + ); if (newValue !== null) { newData[rootPath].__compat.support[browser] = newValue; } From 3a498c16c8eb2e5fd51fa14bd13949f271f16a72 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Fri, 28 Aug 2020 05:28:08 -0700 Subject: [PATCH 09/55] Edge is "true" if Chrome is "true" --- scripts/mirror.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index bfc941f775df32..001d987680832b 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -244,10 +244,9 @@ const bumpEdge = (originalData, chromeData, ieData) => { if (originalData.version_added == true) { newData.version_added = '≤18'; } else { - if ( - chromeData.version_added == true || - Number(chromeData.version_added) <= 79 - ) { + if (chromeData.version_added == true) { + newData.version_added = true; + } else if (Number(chromeData.version_added) <= 79) { if (originalData.version_added == false) { newData.version_added = '79'; } else if (originalData.version_added == null) { From 15416b84288d565e8d5c830cde629d987dc59dad Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Fri, 28 Aug 2020 05:29:16 -0700 Subject: [PATCH 10/55] Update scripts/mirror.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Philip Jägenstedt --- scripts/mirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 001d987680832b..0e64cda3cae2ce 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -219,7 +219,7 @@ const bumpChromeAndroid = (originalData, sourceData, source) => { }; /** - * @param {SupportStatement} compData + * @param {SupportStatement} originalData * @param {SupportStatement} chromeData * @param {SupportStatement} ieData * @returns {SupportStatement} From a0bbcbcbc49d4be904717843d09af346c340b8e3 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Fri, 28 Aug 2020 05:55:53 -0700 Subject: [PATCH 11/55] Set Edge's source as "chrome" --- scripts/mirror.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 0e64cda3cae2ce..f87ac14110e54e 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -88,6 +88,7 @@ const getSource = (browser, forced_source) => { switch (browser) { case 'chrome_android': + case 'edge': case 'opera': source = 'chrome'; break; @@ -99,9 +100,6 @@ const getSource = (browser, forced_source) => { case 'firefox_android': source = 'firefox'; break; - case 'edge': - source = 'ie'; - break; case 'safari_ios': source = 'safari'; break; From d6a5b11af19cb22f0726f49c34bcbd550a60deec Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Mon, 31 Aug 2020 12:27:22 -0700 Subject: [PATCH 12/55] Add warning if Edge has specified --source --- scripts/mirror.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/mirror.js b/scripts/mirror.js index f87ac14110e54e..99e4f3a039b45a 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -745,6 +745,10 @@ const mirrorData = (browser, feature_or_file, forced_source, modify) => { return false; } + if (browser === 'edge' && forced_source) { + console.warn('Warning: Edge does not support --source parameter.'); + } + let source = getSource(browser, forced_source); if (feature_or_file) { From fe28c7c1515eb5464ceaaa003364b698f5060c09 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Tue, 1 Sep 2020 18:35:50 -0700 Subject: [PATCH 13/55] Fix script issues --- scripts/mirror.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/mirror.js b/scripts/mirror.js index 99e4f3a039b45a..ea9a6f067861c3 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -523,6 +523,7 @@ const bumpVersion = (data, destination, source, originalData, compData) => { case 'edge': bumpFunction = (originalData, data, source) => bumpEdge(originalData, data, compData['ie']); + break; case 'opera': bumpFunction = bumpOpera; break; @@ -589,6 +590,7 @@ const doSetFeature = (data, newData, rootPath, browser, source, modify) => { browser, source, compData[browser], + compData, ); if (newValue !== null) { newData[rootPath].__compat.support[browser] = newValue; From a529558ab7b4109532b58888c35fac5b3612ee80 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Fri, 25 Sep 2020 01:48:45 -0700 Subject: [PATCH 14/55] Add negative lookahead to prevent changing the string "Chrome OS" --- scripts/mirror.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index ea9a6f067861c3..1b539cc2fa305c 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -264,7 +264,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { let newNotes = combineNotes( ieData ? updateNotes(ieData.notes, /Internet Explorer/g, 'Edge') : null, - updateNotes(chromeData.notes, /Chrome/g, 'Edge'), + updateNotes(chromeData.notes, /Chrome(?! OS)/g, 'Edge'), originalData.notes, ); @@ -331,7 +331,7 @@ const bumpOpera = (originalData, sourceData, source) => { } if (typeof sourceData.notes === 'string') { - newData.notes = updateNotes(sourceData.notes, /Chrome/g, 'Opera'); + newData.notes = updateNotes(sourceData.notes, /Chrome(?! OS)/g, 'Opera'); } return newData; @@ -364,7 +364,7 @@ const bumpOperaAndroid = (originalData, sourceData, source) => { } if (typeof sourceData.notes === 'string') { - newData.notes = updateNotes(sourceData.notes, /Chrome/g, 'Opera'); + newData.notes = updateNotes(sourceData.notes, /Chrome(?! OS)/g, 'Opera'); } return newData; @@ -428,7 +428,7 @@ const bumpSamsungInternet = (originalData, sourceData, source) => { if (typeof sourceData.notes === 'string') { newData.notes = updateNotes( sourceData.notes, - /Chrome/g, + /Chrome(?! OS)/g, 'Samsung Internet', ); } @@ -471,7 +471,7 @@ const bumpWebView = (originalData, sourceData, source) => { } if (typeof sourceData.notes === 'string') { - newData.notes = updateNotes(sourceData.notes, /Chrome/g, 'WebView'); + newData.notes = updateNotes(sourceData.notes, /Chrome(?! OS)/g, 'WebView'); } return newData; From 6fc1d6c0da29cc44a44d06b9086eb8e57943a1b9 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Fri, 25 Sep 2020 01:51:50 -0700 Subject: [PATCH 15/55] Fix negative lookahead --- scripts/mirror.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 1b539cc2fa305c..3e2a2096301d79 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -264,7 +264,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { let newNotes = combineNotes( ieData ? updateNotes(ieData.notes, /Internet Explorer/g, 'Edge') : null, - updateNotes(chromeData.notes, /Chrome(?! OS)/g, 'Edge'), + updateNotes(chromeData.notes, /Chrome(?! ?OS)/g, 'Edge'), originalData.notes, ); @@ -331,7 +331,7 @@ const bumpOpera = (originalData, sourceData, source) => { } if (typeof sourceData.notes === 'string') { - newData.notes = updateNotes(sourceData.notes, /Chrome(?! OS)/g, 'Opera'); + newData.notes = updateNotes(sourceData.notes, /Chrome(?! ?OS)/g, 'Opera'); } return newData; @@ -364,7 +364,7 @@ const bumpOperaAndroid = (originalData, sourceData, source) => { } if (typeof sourceData.notes === 'string') { - newData.notes = updateNotes(sourceData.notes, /Chrome(?! OS)/g, 'Opera'); + newData.notes = updateNotes(sourceData.notes, /Chrome(?! ?OS)/g, 'Opera'); } return newData; @@ -428,7 +428,7 @@ const bumpSamsungInternet = (originalData, sourceData, source) => { if (typeof sourceData.notes === 'string') { newData.notes = updateNotes( sourceData.notes, - /Chrome(?! OS)/g, + /Chrome(?! ?OS)/g, 'Samsung Internet', ); } @@ -471,7 +471,7 @@ const bumpWebView = (originalData, sourceData, source) => { } if (typeof sourceData.notes === 'string') { - newData.notes = updateNotes(sourceData.notes, /Chrome(?! OS)/g, 'WebView'); + newData.notes = updateNotes(sourceData.notes, /Chrome(?! ?OS)/g, 'WebView'); } return newData; From 7cd6001721548f5eabb87e049d5f68c1d54453d6 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Thu, 8 Oct 2020 16:06:23 -0700 Subject: [PATCH 16/55] Fix mirroring comparison for IE --- scripts/mirror.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 3e2a2096301d79..4a21f417e4eab3 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -226,9 +226,9 @@ const bumpEdge = (originalData, chromeData, ieData) => { let newData = copyStatement(originalData); if (ieData) { - if (ieData.version_removed !== null) { + if (ieData.version_removed || ieData.version_added === false) { newData.version_added = false; - } else if (ieData.version_added !== null) { + } else if (ieData.version_added) { newData.version_added = ieData.version_added ? '12' : null; } } @@ -239,20 +239,21 @@ const bumpEdge = (originalData, chromeData, ieData) => { let chromeNull = chromeData.version_added === null; if (!chromeFalse && !chromeNull) { - if (originalData.version_added == true) { + if (originalData.version_added === true) { newData.version_added = '≤18'; - } else { - if (chromeData.version_added == true) { - newData.version_added = true; - } else if (Number(chromeData.version_added) <= 79) { - if (originalData.version_added == false) { - newData.version_added = '79'; - } else if (originalData.version_added == null) { - newData.version_added = '≤79'; - } - } else { - newData.version_added = chromeData.version_added; + } else if (chromeData.version_added === true) { + newData.version_added = true; + } else if (Number(chromeData.version_added) <= 79) { + if ( + originalData.version_added === false || + newData.version_added === false + ) { + newData.version_added = '79'; + } else if (originalData.version_added === null) { + newData.version_added = '≤79'; } + } else { + newData.version_added = chromeData.version_added; } } else if (chromeFalse) { if (originalData.version_added && !originalData.version_removed) { From 28222fab4f01f3639444248b4be26169404952c8 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Thu, 3 Jun 2021 04:22:11 -0700 Subject: [PATCH 17/55] Account for arrays in bumpEdge() --- scripts/mirror.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/mirror.js b/scripts/mirror.js index 4a21f417e4eab3..b23c2ecc40a013 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -223,6 +223,10 @@ const bumpChromeAndroid = (originalData, sourceData, source) => { * @returns {SupportStatement} */ const bumpEdge = (originalData, chromeData, ieData) => { + if (Array.isArray(originalData)) { + return originalData.map(d => bumpEdge(d)); + } + let newData = copyStatement(originalData); if (ieData) { From 277a894316ba5c2bdc00ab8030b9741992d3c958 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Sat, 5 Jun 2021 18:31:33 -0700 Subject: [PATCH 18/55] Simplify chromeFalse variable --- scripts/mirror.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index b23c2ecc40a013..53319bb66bfb20 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -238,8 +238,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { } let chromeFalse = - chromeData.version_added === false || - chromeData.version_removed !== undefined; + chromeData.version_removed || chromeData.version_added === false; let chromeNull = chromeData.version_added === null; if (!chromeFalse && !chromeNull) { From 925a6bc08b17f4c81a6a85203aa8c213e14c2113 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Sat, 5 Jun 2021 18:31:47 -0700 Subject: [PATCH 19/55] Fix array bumping --- scripts/mirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 53319bb66bfb20..a8ac391cd69bd2 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -224,7 +224,7 @@ const bumpChromeAndroid = (originalData, sourceData, source) => { */ const bumpEdge = (originalData, chromeData, ieData) => { if (Array.isArray(originalData)) { - return originalData.map(d => bumpEdge(d)); + return originalData.map(d => bumpEdge(d, chromeData, ieData)); } let newData = copyStatement(originalData); From 68ca2d19b7540c2d1cc6c2ac1fffb7a75b64ceff Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Tue, 8 Jun 2021 04:12:34 -0700 Subject: [PATCH 20/55] Update scripts/mirror.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Philip Jägenstedt --- scripts/mirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index a8ac391cd69bd2..7cb56b4bca0ad4 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -233,7 +233,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { if (ieData.version_removed || ieData.version_added === false) { newData.version_added = false; } else if (ieData.version_added) { - newData.version_added = ieData.version_added ? '12' : null; + newData.version_added = '12'; } } From 2494c398403fdcfb65c7ae88fe99ea23a7e63b67 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Tue, 8 Jun 2021 06:59:16 -0700 Subject: [PATCH 21/55] Separate IE/Chrome bumping into separate functions --- scripts/mirror.js | 78 +++++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 7cb56b4bca0ad4..606e381b878772 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -216,37 +216,33 @@ const bumpChromeAndroid = (originalData, sourceData, source) => { return newData; }; -/** - * @param {SupportStatement} originalData - * @param {SupportStatement} chromeData - * @param {SupportStatement} ieData - * @returns {SupportStatement} - */ -const bumpEdge = (originalData, chromeData, ieData) => { - if (Array.isArray(originalData)) { - return originalData.map(d => bumpEdge(d, chromeData, ieData)); +const bumpEdgeFromIE = sourceData => { + let newData = copyStatement(sourceData); + + if (sourceData.version_removed || sourceData.version_added === false) { + newData.version_added = false; + } else if (sourceData.version_added) { + newData.version_added = '12'; } - let newData = copyStatement(originalData); + newData.notes = updateNotes(sourceData.notes, /Internet Explorer/g, 'Edge'); - if (ieData) { - if (ieData.version_removed || ieData.version_added === false) { - newData.version_added = false; - } else if (ieData.version_added) { - newData.version_added = '12'; - } - } + return newData; +}; + +const bumpEdgeFromChrome = (sourceData, originalData) => { + let newData = copyStatement(sourceData); let chromeFalse = - chromeData.version_removed || chromeData.version_added === false; - let chromeNull = chromeData.version_added === null; + sourceData.version_removed || sourceData.version_added === false; + let chromeNull = sourceData.version_added === null; if (!chromeFalse && !chromeNull) { if (originalData.version_added === true) { newData.version_added = '≤18'; - } else if (chromeData.version_added === true) { + } else if (sourceData.version_added === true) { newData.version_added = true; - } else if (Number(chromeData.version_added) <= 79) { + } else if (Number(sourceData.version_added) <= 79) { if ( originalData.version_added === false || newData.version_added === false @@ -256,7 +252,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { newData.version_added = '≤79'; } } else { - newData.version_added = chromeData.version_added; + newData.version_added = sourceData.version_added; } } else if (chromeFalse) { if (originalData.version_added && !originalData.version_removed) { @@ -266,14 +262,38 @@ const bumpEdge = (originalData, chromeData, ieData) => { newData.version_added = null; } - let newNotes = combineNotes( - ieData ? updateNotes(ieData.notes, /Internet Explorer/g, 'Edge') : null, - updateNotes(chromeData.notes, /Chrome(?! ?OS)/g, 'Edge'), - originalData.notes, - ); + newData.notes = updateNotes(chromeData.notes, /Chrome(?! ?OS)/g, 'Edge'); - if (newNotes) { - newData.notes = newNotes; + return newData; +}; + +/** + * @param {SupportStatement} originalData + * @param {SupportStatement} chromeData + * @param {SupportStatement} ieData + * @returns {SupportStatement} + */ +const bumpEdge = (originalData, chromeData, ieData) => { + if (Array.isArray(originalData)) { + return originalData.map(d => bumpEdge(d, chromeData, ieData)); + } + + let newData = []; + + if (ieData) { + if (Array.isArray(ieData)) { + newData += ieData.map(d => bumpEdgeFromIE(d)); + } else { + newData.push(bumpEdgeFromIE(ieData)); + } + } + + if (chromeData) { + if (Array.isArray(chromeData)) { + newData += chromeData.map(d => bumpEdgeFromChrome(d, originalData)); + } else { + newData.push(bumpEdgeFromChrome(chromeData, originalData)); + } } return newData; From 99d076cd0c504b28849c499bd8995027067146da Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 9 Jun 2021 04:06:04 -0700 Subject: [PATCH 22/55] Fix syntax for notes combination filtering --- scripts/mirror.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 606e381b878772..57220c395b6c9c 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -136,9 +136,7 @@ const combineNotes = (notes1, notes2) => { } } - newNotes = newNotes.filter((item, pos) => { - newNotes.indexOf(item) == pos; - }); + newNotes = newNotes.filter((item, pos) => newNotes.indexOf(item) == pos); if (newNotes.length == 0) { return null; From d21ae6b2817d0f6589f233f7bb6920030ab666b7 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 9 Jun 2021 04:07:20 -0700 Subject: [PATCH 23/55] Add combineStatements function --- scripts/mirror.js | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/scripts/mirror.js b/scripts/mirror.js index 57220c395b6c9c..e1c2255d39300f 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -183,6 +183,56 @@ const copyStatement = data => { return newData; }; +/** + * @param {...SupportStatement} data + * @returns {SupportStatement} + */ +const combineStatements = (...data) => { + const ignored_keys = ['version_added', 'notes']; + + let flattenedData = data.flat(2); + let sections = {}; + let newData = []; + + for (const d of flattenedData) { + let key = Object.keys(d) + .filter(k => !ignored_keys.includes(k)) + .join(''); + if (!(key in sections)) sections[key] = []; + sections[key].push(d); + } + + for (const k of Object.keys(sections)) { + let currentStatement = sections[k][0]; + + if (sections[k].length == 1) { + newData.push(currentStatement); + continue; + } + + for (const i in sections[k]) { + if (i == 0) continue; + let newStatement = sections[k][i]; + + if ( + compareVersions.compare( + currentStatement.version_added, + newStatement.version_added, + '>', + ) + ) + currentStatement.version_added = newStatement.version_added; + + let newNotes = combineNotes(currentStatement.notes, newStatement.notes); + if (newNotes) currentStatement.notes = newNotes; + } + + newData.push(currentStatement); + } + + return newData; +}; + /** * @param {SupportStatement} originalData * @param {SupportStatement} sourceData From ce50cfa2e23681121ad0c24d6e82881e510f0284 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 9 Jun 2021 04:08:17 -0700 Subject: [PATCH 24/55] Hook up combineStatements to bumpEdge --- scripts/mirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index e1c2255d39300f..6c85d09d6abc2f 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -344,7 +344,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { } } - return newData; + return combineStatements(...newData); }; /** From cb4bc991b0ff351b850ed3c820fdf12777361c40 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 9 Jun 2021 04:12:48 -0700 Subject: [PATCH 25/55] Account for ranged values --- scripts/mirror.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 6c85d09d6abc2f..44e04041ffe48e 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -216,8 +216,8 @@ const combineStatements = (...data) => { if ( compareVersions.compare( - currentStatement.version_added, - newStatement.version_added, + currentStatement.version_added.replace('≤', ''), + newStatement.version_added.replace('≤', ''), '>', ) ) From b87e41f5633f5f053f8a3770e547a4e400420037 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 9 Jun 2021 04:24:39 -0700 Subject: [PATCH 26/55] Simplify code for when Chrome === true --- scripts/mirror.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 44e04041ffe48e..679ed9a86817ca 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -286,10 +286,9 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { let chromeNull = sourceData.version_added === null; if (!chromeFalse && !chromeNull) { - if (originalData.version_added === true) { - newData.version_added = '≤18'; - } else if (sourceData.version_added === true) { - newData.version_added = true; + if (sourceData.version_added === true) { + newData.version_added = + originalData.version_added === true ? '≤18' : true; } else if (Number(sourceData.version_added) <= 79) { if ( originalData.version_added === false || From e4a7cae8c830169c194376c5ca8e13344e8276f4 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 9 Jun 2021 04:25:03 -0700 Subject: [PATCH 27/55] Restructure code --- scripts/mirror.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 679ed9a86817ca..4a763978a9effb 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -285,7 +285,13 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { sourceData.version_removed || sourceData.version_added === false; let chromeNull = sourceData.version_added === null; - if (!chromeFalse && !chromeNull) { + if (chromeFalse) { + if (originalData.version_added && !originalData.version_removed) { + newData.version_removed = '79'; + } + } else if (chromeNull) { + newData.version_added = null; + } else { if (sourceData.version_added === true) { newData.version_added = originalData.version_added === true ? '≤18' : true; @@ -301,12 +307,6 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { } else { newData.version_added = sourceData.version_added; } - } else if (chromeFalse) { - if (originalData.version_added && !originalData.version_removed) { - newData.version_removed = '79'; - } - } else if (chromeNull) { - newData.version_added = null; } newData.notes = updateNotes(chromeData.notes, /Chrome(?! ?OS)/g, 'Edge'); From 9979d1b032070e5daa786b7f89a19e7ab62fe93b Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 9 Jun 2021 04:27:00 -0700 Subject: [PATCH 28/55] Remove redundant clause --- scripts/mirror.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 4a763978a9effb..8b6ce286e0b006 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -296,10 +296,7 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { newData.version_added = originalData.version_added === true ? '≤18' : true; } else if (Number(sourceData.version_added) <= 79) { - if ( - originalData.version_added === false || - newData.version_added === false - ) { + if (originalData.version_added === false) { newData.version_added = '79'; } else if (originalData.version_added === null) { newData.version_added = '≤79'; From fefa28a748b48b46a57b17c8d89022c93d31d5d6 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 9 Jun 2021 04:33:20 -0700 Subject: [PATCH 29/55] Resolve statement merging --- scripts/mirror.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 8b6ce286e0b006..d4ebc9f266f812 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -214,14 +214,27 @@ const combineStatements = (...data) => { if (i == 0) continue; let newStatement = sections[k][i]; - if ( - compareVersions.compare( - currentStatement.version_added.replace('≤', ''), - newStatement.version_added.replace('≤', ''), - '>', - ) - ) - currentStatement.version_added = newStatement.version_added; + let currentVA = currentStatement.version_added; + let newVA = newStatement.version_added; + + if (newVA === false) { + // Ignore statements with version_added being false + continue; + } else if (typeof newVA === 'string') { + if (typeof currentVA === 'string') { + if ( + compareVersions.compare( + currentVA.replace('≤', ''), + newVA.replace('≤', ''), + '>', + ) + ) { + currentStatement.version_added = newVA; + } + } else { + currentStatement.version_added = currentVA || newVA; + } + } let newNotes = combineNotes(currentStatement.notes, newStatement.notes); if (newNotes) currentStatement.notes = newNotes; From 9dfe0baab1385bdbef81c3ef38ebd94b41fa2c49 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 9 Jun 2021 04:37:23 -0700 Subject: [PATCH 30/55] Fix notes copying --- scripts/mirror.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index d4ebc9f266f812..ca0d9279445bb6 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -238,6 +238,7 @@ const combineStatements = (...data) => { let newNotes = combineNotes(currentStatement.notes, newStatement.notes); if (newNotes) currentStatement.notes = newNotes; + else if ('notes' in currentStatement) delete currentStatement.notes; } newData.push(currentStatement); @@ -319,7 +320,7 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { } } - newData.notes = updateNotes(chromeData.notes, /Chrome(?! ?OS)/g, 'Edge'); + newData.notes = updateNotes(sourceData.notes, /Chrome(?! ?OS)/g, 'Edge'); return newData; }; From 2f0eb1f0dafe768e939a51cca902b5edea5a537b Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 9 Jun 2021 04:38:55 -0700 Subject: [PATCH 31/55] De-array a single-statement array from combineStatements --- scripts/mirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index ca0d9279445bb6..d71b2a754c2f0d 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -244,7 +244,7 @@ const combineStatements = (...data) => { newData.push(currentStatement); } - return newData; + return newData.length === 1 ? newData[0] : newData; }; /** From 2e7b708b9e4da705f7e2b0c44732e42615f78c4f Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 9 Jun 2021 04:43:29 -0700 Subject: [PATCH 32/55] Prevent addition of "notes": null in statements --- scripts/mirror.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index d71b2a754c2f0d..73c22a46bbac07 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -238,9 +238,10 @@ const combineStatements = (...data) => { let newNotes = combineNotes(currentStatement.notes, newStatement.notes); if (newNotes) currentStatement.notes = newNotes; - else if ('notes' in currentStatement) delete currentStatement.notes; } + if ('notes' in currentStatement && !currentStatement.notes) + delete currentStatement.notes; newData.push(currentStatement); } @@ -287,7 +288,8 @@ const bumpEdgeFromIE = sourceData => { newData.version_added = '12'; } - newData.notes = updateNotes(sourceData.notes, /Internet Explorer/g, 'Edge'); + let newNotes = updateNotes(sourceData.notes, /Internet Explorer/g, 'Edge'); + if (newNotes) newData.notes = newNotes; return newData; }; @@ -320,7 +322,8 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { } } - newData.notes = updateNotes(sourceData.notes, /Chrome(?! ?OS)/g, 'Edge'); + let newNotes = updateNotes(sourceData.notes, /Chrome(?! ?OS)/g, 'Edge'); + if (newNotes) newData.notes = newNotes; return newData; }; From 59f346d685f3ec398fbed927285507659a20e294 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Wed, 9 Jun 2021 05:07:51 -0700 Subject: [PATCH 33/55] Update JSDocs --- scripts/mirror.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/mirror.js b/scripts/mirror.js index 73c22a46bbac07..9bd474992c031b 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -279,6 +279,10 @@ const bumpChromeAndroid = (originalData, sourceData, source) => { return newData; }; +/** + * @param {SupportStatement} sourceData + * @returns {SupportStatement} + */ const bumpEdgeFromIE = sourceData => { let newData = copyStatement(sourceData); @@ -294,6 +298,11 @@ const bumpEdgeFromIE = sourceData => { return newData; }; +/** + * @param {SupportStatement} sourceData + * @param {SupportStatement} originalData + * @returns {SupportStatement} + */ const bumpEdgeFromChrome = (sourceData, originalData) => { let newData = copyStatement(sourceData); From 9e05539922dcfcb9273455d165832f8288bc06d3 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Thu, 10 Jun 2021 21:43:26 -0700 Subject: [PATCH 34/55] Fix syntax --- scripts/mirror.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 9bd474992c031b..d8e789418511c5 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -352,7 +352,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { if (ieData) { if (Array.isArray(ieData)) { - newData += ieData.map(d => bumpEdgeFromIE(d)); + newData.concat(ieData.map(d => bumpEdgeFromIE(d))); } else { newData.push(bumpEdgeFromIE(ieData)); } @@ -360,7 +360,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { if (chromeData) { if (Array.isArray(chromeData)) { - newData += chromeData.map(d => bumpEdgeFromChrome(d, originalData)); + newData.concat(chromeData.map(d => bumpEdgeFromChrome(d, originalData))); } else { newData.push(bumpEdgeFromChrome(chromeData, originalData)); } From a8aaf2430f125a7efa158e8a3e8bcf51d410b684 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Tue, 27 Jul 2021 12:10:41 -0700 Subject: [PATCH 35/55] Simplify version bumping logic --- scripts/mirror.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index d8e789418511c5..01c3d6b77ad0ad 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -321,11 +321,8 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { newData.version_added = originalData.version_added === true ? '≤18' : true; } else if (Number(sourceData.version_added) <= 79) { - if (originalData.version_added === false) { - newData.version_added = '79'; - } else if (originalData.version_added === null) { - newData.version_added = '≤79'; - } + newData.version_added = + originalData.version_added === null ? '≤79' : '79'; } else { newData.version_added = sourceData.version_added; } From f983ed8a230bf9ece79c19f6fa94ce07e811d337 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Tue, 27 Jul 2021 12:30:04 -0700 Subject: [PATCH 36/55] Simplify logic for choosing version bump function --- scripts/mirror.js | 48 +++++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 01c3d6b77ad0ad..1fc23ad144069f 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -602,39 +602,21 @@ const bumpVersion = (data, destination, source, originalData, compData) => { ); } } else { - let bumpFunction = null; - - switch (destination) { - case 'chrome_android': - bumpFunction = bumpChromeAndroid; - break; - case 'firefox_android': - bumpFunction = bumpFirefoxAndroid; - break; - case 'edge': - bumpFunction = (originalData, data, source) => - bumpEdge(originalData, data, compData['ie']); - break; - case 'opera': - bumpFunction = bumpOpera; - break; - case 'opera_android': - bumpFunction = bumpOperaAndroid; - break; - case 'safari_ios': - bumpFunction = bumpSafariiOS; - break; - case 'samsunginternet_android': - bumpFunction = bumpSamsungInternet; - break; - case 'webview_android': - bumpFunction = bumpWebView; - break; - default: - bumpFunction = bumpGeneric; - break; - } - + const bumpFunctions = { + generic: bumpGeneric, + chrome_android: bumpChromeAndroid, + firefox_android: bumpFirefoxAndroid, + edge: (originalData, data, source) => + bumpEdge(originalData, data, compData['ie']), + opera: bumpOpera, + opera_android: bumpOperaAndroid, + safari_ios: bumpSafariiOS, + samsunginternet_android: bumpSamsungInternet, + webview_android: bumpWebView, + }; + + let bumpFunction = + bumpFunctions[destination in bumpFunctions ? destination : 'generic']; newData = bumpFunction(originalData, data, source); } From 45ba87ceeeae3eee678612a9c4cb65cc83f3840b Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Tue, 27 Jul 2021 12:38:31 -0700 Subject: [PATCH 37/55] Let each individual mirroring function handle array bumping --- scripts/mirror.js | 88 +++++++++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 30 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 1fc23ad144069f..e70cfca298b6a7 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -255,6 +255,12 @@ const combineStatements = (...data) => { * @returns {SupportStatement} */ const bumpChromeAndroid = (originalData, sourceData, source) => { + if (Array.isArray(sourceData)) { + return combineStatements( + ...sourceData.map(d => bumpChromeAndroid(originalData, d, source)), + ); + } + let newData = copyStatement(sourceData); if (typeof sourceData.version_added === 'string') { @@ -373,6 +379,12 @@ const bumpEdge = (originalData, chromeData, ieData) => { * @returns {SupportStatement} */ const bumpFirefoxAndroid = (originalData, sourceData, source) => { + if (Array.isArray(sourceData)) { + return combineStatements( + ...sourceData.map(d => bumpFirefoxAndroid(originalData, d, source)), + ); + } + let newData = copyStatement(sourceData); if (typeof sourceData.version_added === 'string') { @@ -402,6 +414,12 @@ const bumpFirefoxAndroid = (originalData, sourceData, source) => { * @returns {SupportStatement} */ const bumpOpera = (originalData, sourceData, source) => { + if (Array.isArray(sourceData)) { + return combineStatements( + ...sourceData.map(d => bumpOpera(originalData, d, source)), + ); + } + let newData = copyStatement(sourceData); if (typeof sourceData.version_added === 'string') { @@ -435,6 +453,12 @@ const bumpOpera = (originalData, sourceData, source) => { * @returns {SupportStatement} */ const bumpOperaAndroid = (originalData, sourceData, source) => { + if (Array.isArray(sourceData)) { + return combineStatements( + ...sourceData.map(d => bumpOperaAndroid(originalData, d, source)), + ); + } + let newData = copyStatement(sourceData); if (typeof sourceData.version_added === 'string') { @@ -468,6 +492,12 @@ const bumpOperaAndroid = (originalData, sourceData, source) => { * @returns {SupportStatement} */ const bumpSafariiOS = (originalData, sourceData, source) => { + if (Array.isArray(sourceData)) { + return combineStatements( + ...sourceData.map(d => bumpSafariiOS(originalData, d, source)), + ); + } + let newData = copyStatement(sourceData); if (typeof sourceData.version_added === 'string') { @@ -497,6 +527,12 @@ const bumpSafariiOS = (originalData, sourceData, source) => { * @returns {SupportStatement} */ const bumpSamsungInternet = (originalData, sourceData, source) => { + if (Array.isArray(sourceData)) { + return combineStatements( + ...sourceData.map(d => bumpSamsungInternet(originalData, d, source)), + ); + } + let newData = copyStatement(sourceData); if (typeof sourceData.version_added === 'string') { @@ -534,6 +570,12 @@ const bumpSamsungInternet = (originalData, sourceData, source) => { * @returns {SupportStatement} */ const bumpWebView = (originalData, sourceData, source) => { + if (Array.isArray(sourceData)) { + return combineStatements( + ...sourceData.map(d => bumpWebView(originalData, d, source)), + ); + } + let newData = copyStatement(sourceData); const createWebViewRange = version => { @@ -587,40 +629,26 @@ const bumpGeneric = (originalData, sourceData, source) => { * @param {SupportStatement} compData */ const bumpVersion = (data, destination, source, originalData, compData) => { - let newData = null; if (data == null) { return null; - } else if (Array.isArray(data)) { - newData = []; - for (let i = 0; i < data.length; i++) { - newData[i] = bumpVersion( - data[i], - destination, - source, - originalData, - compData, - ); - } - } else { - const bumpFunctions = { - generic: bumpGeneric, - chrome_android: bumpChromeAndroid, - firefox_android: bumpFirefoxAndroid, - edge: (originalData, data, source) => - bumpEdge(originalData, data, compData['ie']), - opera: bumpOpera, - opera_android: bumpOperaAndroid, - safari_ios: bumpSafariiOS, - samsunginternet_android: bumpSamsungInternet, - webview_android: bumpWebView, - }; - - let bumpFunction = - bumpFunctions[destination in bumpFunctions ? destination : 'generic']; - newData = bumpFunction(originalData, data, source); } - return newData; + const bumpFunctions = { + generic: bumpGeneric, + chrome_android: bumpChromeAndroid, + firefox_android: bumpFirefoxAndroid, + edge: (originalData, data, source) => + bumpEdge(originalData, data, compData['ie']), + opera: bumpOpera, + opera_android: bumpOperaAndroid, + safari_ios: bumpSafariiOS, + samsunginternet_android: bumpSamsungInternet, + webview_android: bumpWebView, + }; + + let bumpFunction = + bumpFunctions[destination in bumpFunctions ? destination : 'generic']; + return bumpFunction(originalData, data, source); }; /** From 80691657235da36b41720061585c71d796d1ba55 Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Tue, 27 Jul 2021 12:48:28 -0700 Subject: [PATCH 38/55] Fix data concatenation --- scripts/mirror.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index e70cfca298b6a7..dc414614c960e8 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -355,7 +355,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { if (ieData) { if (Array.isArray(ieData)) { - newData.concat(ieData.map(d => bumpEdgeFromIE(d))); + newData = newData.concat(ieData.map(d => bumpEdgeFromIE(d))); } else { newData.push(bumpEdgeFromIE(ieData)); } @@ -363,7 +363,9 @@ const bumpEdge = (originalData, chromeData, ieData) => { if (chromeData) { if (Array.isArray(chromeData)) { - newData.concat(chromeData.map(d => bumpEdgeFromChrome(d, originalData))); + newData = newData.concat( + chromeData.map(d => bumpEdgeFromChrome(d, originalData)), + ); } else { newData.push(bumpEdgeFromChrome(chromeData, originalData)); } From 333fe2ea28a4e0fe4921a3de4a8e997025f8115b Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Tue, 27 Jul 2021 12:48:51 -0700 Subject: [PATCH 39/55] Ignore statements removed in Chrome before Edgium existed --- scripts/mirror.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/mirror.js b/scripts/mirror.js index dc414614c960e8..3f516922a7fd03 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -317,6 +317,10 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { let chromeNull = sourceData.version_added === null; if (chromeFalse) { + if (sourceData.version_removed <= 79) { + // If this feature was removed before Edgium existed, ignore + return {}; + } if (originalData.version_added && !originalData.version_removed) { newData.version_removed = '79'; } From 4e2c649ff5f682414be1e4e073458f15d78fcd9d Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Tue, 27 Jul 2021 12:57:01 -0700 Subject: [PATCH 40/55] Combine statements when Edge's original data is an array --- scripts/mirror.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 3f516922a7fd03..9c7ac958dea651 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -352,7 +352,9 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { */ const bumpEdge = (originalData, chromeData, ieData) => { if (Array.isArray(originalData)) { - return originalData.map(d => bumpEdge(d, chromeData, ieData)); + return combineStatements( + ...originalData.map(d => bumpEdge(d, chromeData, ieData)), + ); } let newData = []; From 096a519e744f1909f931de06fdd9e6865fd5bd5c Mon Sep 17 00:00:00 2001 From: Queen Vinyl Darkscratch Date: Tue, 27 Jul 2021 12:57:09 -0700 Subject: [PATCH 41/55] Filter combined statements --- scripts/mirror.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/mirror.js b/scripts/mirror.js index 9c7ac958dea651..fefc97c85ab147 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -245,6 +245,13 @@ const combineStatements = (...data) => { newData.push(currentStatement); } + if (newData.length === 1) return newData[0]; + + // Remove duplicate statements and statements that are only version_added = false + newData = newData + .filter((item, pos) => newData.indexOf(item) == pos) + .filter(item => item.version_added); + return newData.length === 1 ? newData[0] : newData; }; From 8a098015c7c84c256c8f3a33d2c31d663e99431c Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Sat, 9 Oct 2021 06:50:41 -0700 Subject: [PATCH 42/55] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Philip Jägenstedt --- scripts/mirror.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index fefc97c85ab147..f7ce9a8b2e5249 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -325,7 +325,7 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { if (chromeFalse) { if (sourceData.version_removed <= 79) { - // If this feature was removed before Edgium existed, ignore + // If this feature was removed before Chrome 79, ignore return {}; } if (originalData.version_added && !originalData.version_removed) { @@ -662,7 +662,7 @@ const bumpVersion = (data, destination, source, originalData, compData) => { }; let bumpFunction = - bumpFunctions[destination in bumpFunctions ? destination : 'generic']; + bumpFunctions[destination] || bumpFunctions.generic; return bumpFunction(originalData, data, source); }; From aefbc323481e9472ee3bfd91d1e92a246d1a9b41 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Sat, 9 Oct 2021 06:54:53 -0700 Subject: [PATCH 43/55] Apply suggestions from review --- scripts/mirror.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index f7ce9a8b2e5249..93e7d52353e307 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -211,7 +211,7 @@ const combineStatements = (...data) => { } for (const i in sections[k]) { - if (i == 0) continue; + if (i === 0) continue; let newStatement = sections[k][i]; let currentVA = currentStatement.version_added; @@ -324,7 +324,7 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { let chromeNull = sourceData.version_added === null; if (chromeFalse) { - if (sourceData.version_removed <= 79) { + if (compareVersions.compare(sourceData.version_removed, '79', '<=')) { // If this feature was removed before Chrome 79, ignore return {}; } @@ -337,7 +337,7 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { if (sourceData.version_added === true) { newData.version_added = originalData.version_added === true ? '≤18' : true; - } else if (Number(sourceData.version_added) <= 79) { + } else if (compareVersions.compare(sourceData.version_added, '79', '<=')) { newData.version_added = originalData.version_added === null ? '≤79' : '79'; } else { @@ -661,8 +661,7 @@ const bumpVersion = (data, destination, source, originalData, compData) => { webview_android: bumpWebView, }; - let bumpFunction = - bumpFunctions[destination] || bumpFunctions.generic; + let bumpFunction = bumpFunctions[destination] || bumpFunctions.generic; return bumpFunction(originalData, data, source); }; From 23db74af44648e3764d1daf1a17b6c8795e3a37f Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Wed, 10 Nov 2021 03:12:19 -0800 Subject: [PATCH 44/55] Improve combineStatements logic --- scripts/mirror.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 93e7d52353e307..88318c78a0e888 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -221,18 +221,15 @@ const combineStatements = (...data) => { // Ignore statements with version_added being false continue; } else if (typeof newVA === 'string') { - if (typeof currentVA === 'string') { - if ( - compareVersions.compare( - currentVA.replace('≤', ''), - newVA.replace('≤', ''), - '>', - ) - ) { - currentStatement.version_added = newVA; - } - } else { - currentStatement.version_added = currentVA || newVA; + if ( + typeof currentVA !== 'string' || + compareVersions.compare( + currentVA.replace('≤', ''), + newVA.replace('≤', ''), + '>', + ) + ) { + currentStatement.version_added = newVA; } } From d74b1ff46c3f96b92a5a5e51019fbc26c48fd0f8 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Sat, 13 Nov 2021 08:27:34 -0800 Subject: [PATCH 45/55] Make sure version_removed is version number before comparing --- scripts/mirror.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 88318c78a0e888..6bea7218ee2c85 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -321,7 +321,10 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { let chromeNull = sourceData.version_added === null; if (chromeFalse) { - if (compareVersions.compare(sourceData.version_removed, '79', '<=')) { + if ( + typeof sourceData.version_removed === 'string' && + compareVersions.compare(sourceData.version_removed, '79', '<=') + ) { // If this feature was removed before Chrome 79, ignore return {}; } From 2f2f7fd87b2427a7c49f0ce9b850e3cd0f2330ce Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 3 May 2022 04:25:27 -0700 Subject: [PATCH 46/55] Format --- scripts/mirror.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 2360955cf7de17..7eed06a1d4d89a 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -220,7 +220,7 @@ const combineStatements = (...data) => { for (const d of flattenedData) { let key = Object.keys(d) - .filter(k => !ignored_keys.includes(k)) + .filter((k) => !ignored_keys.includes(k)) .join(''); if (!(key in sections)) sections[key] = []; sections[key].push(d); @@ -271,7 +271,7 @@ const combineStatements = (...data) => { // Remove duplicate statements and statements that are only version_added = false newData = newData .filter((item, pos) => newData.indexOf(item) == pos) - .filter(item => item.version_added); + .filter((item) => item.version_added); return newData.length === 1 ? newData[0] : newData; }; @@ -285,7 +285,7 @@ const combineStatements = (...data) => { const bumpChromeAndroid = (originalData, sourceData, source) => { if (Array.isArray(sourceData)) { return combineStatements( - ...sourceData.map(d => bumpChromeAndroid(originalData, d, source)), + ...sourceData.map((d) => bumpChromeAndroid(originalData, d, source)), ); } @@ -317,7 +317,7 @@ const bumpChromeAndroid = (originalData, sourceData, source) => { * @param {SupportStatement} sourceData * @returns {SupportStatement} */ -const bumpEdgeFromIE = sourceData => { +const bumpEdgeFromIE = (sourceData) => { let newData = copyStatement(sourceData); if (sourceData.version_removed || sourceData.version_added === false) { @@ -384,7 +384,7 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { const bumpEdge = (originalData, chromeData, ieData) => { if (Array.isArray(originalData)) { return combineStatements( - ...originalData.map(d => bumpEdge(d, chromeData, ieData)), + ...originalData.map((d) => bumpEdge(d, chromeData, ieData)), ); } @@ -392,7 +392,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { if (ieData) { if (Array.isArray(ieData)) { - newData = newData.concat(ieData.map(d => bumpEdgeFromIE(d))); + newData = newData.concat(ieData.map((d) => bumpEdgeFromIE(d))); } else { newData.push(bumpEdgeFromIE(ieData)); } @@ -401,7 +401,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { if (chromeData) { if (Array.isArray(chromeData)) { newData = newData.concat( - chromeData.map(d => bumpEdgeFromChrome(d, originalData)), + chromeData.map((d) => bumpEdgeFromChrome(d, originalData)), ); } else { newData.push(bumpEdgeFromChrome(chromeData, originalData)); @@ -420,7 +420,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { const bumpFirefoxAndroid = (originalData, sourceData, source) => { if (Array.isArray(sourceData)) { return combineStatements( - ...sourceData.map(d => bumpFirefoxAndroid(originalData, d, source)), + ...sourceData.map((d) => bumpFirefoxAndroid(originalData, d, source)), ); } @@ -455,7 +455,7 @@ const bumpFirefoxAndroid = (originalData, sourceData, source) => { const bumpOpera = (originalData, sourceData, source) => { if (Array.isArray(sourceData)) { return combineStatements( - ...sourceData.map(d => bumpOpera(originalData, d, source)), + ...sourceData.map((d) => bumpOpera(originalData, d, source)), ); } @@ -494,7 +494,7 @@ const bumpOpera = (originalData, sourceData, source) => { const bumpOperaAndroid = (originalData, sourceData, source) => { if (Array.isArray(sourceData)) { return combineStatements( - ...sourceData.map(d => bumpOperaAndroid(originalData, d, source)), + ...sourceData.map((d) => bumpOperaAndroid(originalData, d, source)), ); } @@ -533,7 +533,7 @@ const bumpOperaAndroid = (originalData, sourceData, source) => { const bumpSafariiOS = (originalData, sourceData, source) => { if (Array.isArray(sourceData)) { return combineStatements( - ...sourceData.map(d => bumpSafariiOS(originalData, d, source)), + ...sourceData.map((d) => bumpSafariiOS(originalData, d, source)), ); } @@ -568,7 +568,7 @@ const bumpSafariiOS = (originalData, sourceData, source) => { const bumpSamsungInternet = (originalData, sourceData, source) => { if (Array.isArray(sourceData)) { return combineStatements( - ...sourceData.map(d => bumpSamsungInternet(originalData, d, source)), + ...sourceData.map((d) => bumpSamsungInternet(originalData, d, source)), ); } @@ -611,7 +611,7 @@ const bumpSamsungInternet = (originalData, sourceData, source) => { const bumpWebView = (originalData, sourceData, source) => { if (Array.isArray(sourceData)) { return combineStatements( - ...sourceData.map(d => bumpWebView(originalData, d, source)), + ...sourceData.map((d) => bumpWebView(originalData, d, source)), ); } From 6ce7f3fd9046377522b270d452ff6f980b12982b Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 3 May 2022 04:25:55 -0700 Subject: [PATCH 47/55] Handle empty newData array --- scripts/mirror.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 7eed06a1d4d89a..441025ba54fd13 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -273,7 +273,11 @@ const combineStatements = (...data) => { .filter((item, pos) => newData.indexOf(item) == pos) .filter((item) => item.version_added); - return newData.length === 1 ? newData[0] : newData; + return newData.length === 0 + ? { version_added: false } + : newData.length === 1 + ? newData[0] + : newData; }; /** From c0db3d1a99b42911394bd9c3ea5643f356fa3c9e Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 3 May 2022 04:33:46 -0700 Subject: [PATCH 48/55] =?UTF-8?q?Handle=20Chromium=20=E2=89=A479=20removal?= =?UTF-8?q?=20better?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/mirror.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 441025ba54fd13..b6c87b6bd51466 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -353,8 +353,8 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { typeof sourceData.version_removed === 'string' && compareVersions.compare(sourceData.version_removed, '79', '<=') ) { - // If this feature was removed before Chrome 79, ignore - return {}; + // If this feature was removed before Chrome 79, it's not present in Edge + return { version_added: false }; } if (originalData.version_added && !originalData.version_removed) { newData.version_removed = '79'; From 6c532db2b9e16e43b78dc1d4cd060c4430c2a97a Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 3 May 2022 04:36:24 -0700 Subject: [PATCH 49/55] Bump version_added on added-and-removed statements --- scripts/mirror.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/mirror.js b/scripts/mirror.js index b6c87b6bd51466..3d8145f32aed03 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -356,6 +356,14 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { // If this feature was removed before Chrome 79, it's not present in Edge return { version_added: false }; } + if (compareVersions.compare(sourceData.version_added, '79', '<=')) { + // If the feature was added before Chrome 79 but removed afterwards + if (typeof originalData.version_added == 'string') { + newData.version_added = originalData.version_added; + } else { + newData.version_added = '79'; + } + } if (originalData.version_added && !originalData.version_removed) { newData.version_removed = '79'; } From 0b755fd655229b2cb91449fae95b4f03014ba6a8 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 3 May 2022 05:21:38 -0700 Subject: [PATCH 50/55] Allow specifying a source for Edge again --- scripts/mirror.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 3d8145f32aed03..05e4534b78b840 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -112,7 +112,6 @@ const getSource = (browser, forced_source) => { switch (browser) { case 'chrome_android': - case 'edge': case 'opera': source = 'chrome'; break; @@ -127,6 +126,8 @@ const getSource = (browser, forced_source) => { case 'safari_ios': source = 'safari'; break; + case 'edge': + source = 'chrome-ie'; default: throw Error( `${browser} is a base browser and a "source" browser must be specified.`, @@ -402,7 +403,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { let newData = []; - if (ieData) { + if (ieData && source !== 'chrome') { if (Array.isArray(ieData)) { newData = newData.concat(ieData.map((d) => bumpEdgeFromIE(d))); } else { @@ -410,7 +411,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { } } - if (chromeData) { + if (chromeData && source !== 'ie') { if (Array.isArray(chromeData)) { newData = newData.concat( chromeData.map((d) => bumpEdgeFromChrome(d, originalData)), @@ -898,10 +899,6 @@ const mirrorData = (browser, feature_or_path_array, forced_source, modify) => { return false; } - if (browser === 'edge' && forced_source) { - console.warn('Warning: Edge does not support --source parameter.'); - } - let source = getSource(browser, forced_source); for (const feature_or_path of feature_or_path_array) { From 4111697f3b88212c5a7d1158c6636b064b839234 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 3 May 2022 05:21:59 -0700 Subject: [PATCH 51/55] Add missing break; --- scripts/mirror.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/mirror.js b/scripts/mirror.js index 05e4534b78b840..75c7bc6968d2d4 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -128,6 +128,7 @@ const getSource = (browser, forced_source) => { break; case 'edge': source = 'chrome-ie'; + break; default: throw Error( `${browser} is a base browser and a "source" browser must be specified.`, From 6045cd3bf58543a4f7f69237fb41c3544a13b0fe Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 3 May 2022 05:26:53 -0700 Subject: [PATCH 52/55] Improve source selection code --- scripts/mirror.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 26028e7dc904a8..70b5f6d30940db 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -394,9 +394,16 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { * @param {SupportStatement} originalData * @param {SupportStatement} chromeData * @param {SupportStatement} ieData + * @param {string} source * @returns {SupportStatement} */ -const bumpEdge = (originalData, chromeData, ieData) => { +const bumpEdge = (originalData, chromeData, ieData, source) => { + if (!['chrome-ie', 'chrome', 'ie'].includes(source)) { + throw new Error( + `Source browser "${source}" is invalid for Edge. Valid options are: chrome, ie, chrome-ie`, + ); + } + if (Array.isArray(originalData)) { return combineStatements( ...originalData.map((d) => bumpEdge(d, chromeData, ieData)), @@ -405,7 +412,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { let newData = []; - if (ieData && source !== 'chrome') { + if (ieData && source.includes('ie')) { if (Array.isArray(ieData)) { newData = newData.concat(ieData.map((d) => bumpEdgeFromIE(d))); } else { @@ -413,7 +420,7 @@ const bumpEdge = (originalData, chromeData, ieData) => { } } - if (chromeData && source !== 'ie') { + if (chromeData && source.includes('chrome')) { if (Array.isArray(chromeData)) { newData = newData.concat( chromeData.map((d) => bumpEdgeFromChrome(d, originalData)), @@ -692,7 +699,7 @@ const bumpVersion = (data, destination, source, originalData, compData) => { chrome_android: bumpChromeAndroid, firefox_android: bumpFirefoxAndroid, edge: (originalData, data, source) => - bumpEdge(originalData, data, compData['ie']), + bumpEdge(originalData, compData['chrome'], compData['ie'], source), opera: bumpOpera, opera_android: bumpOperaAndroid, safari_ios: bumpSafariiOS, From 38dc64b801a62751ae2ca5da03d58e66e8f424fa Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 3 May 2022 05:30:00 -0700 Subject: [PATCH 53/55] Ensure sourceData.version_added is string before performing comparison --- scripts/mirror.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 70b5f6d30940db..04a2d19960f1a1 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -359,7 +359,11 @@ const bumpEdgeFromChrome = (sourceData, originalData) => { // If this feature was removed before Chrome 79, it's not present in Edge return { version_added: false }; } - if (compareVersions.compare(sourceData.version_added, '79', '<=')) { + + if ( + typeof sourceData.version_added === 'string' && + compareVersions.compare(sourceData.version_added, '79', '<=') + ) { // If the feature was added before Chrome 79 but removed afterwards if (typeof originalData.version_added == 'string') { newData.version_added = originalData.version_added; From 3a0cb7baa4c6c9fa6420a416cf860118bcd62b8c Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 3 May 2022 05:31:56 -0700 Subject: [PATCH 54/55] Fix run on arrays --- scripts/mirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 04a2d19960f1a1..8a41ae225698a8 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -410,7 +410,7 @@ const bumpEdge = (originalData, chromeData, ieData, source) => { if (Array.isArray(originalData)) { return combineStatements( - ...originalData.map((d) => bumpEdge(d, chromeData, ieData)), + ...originalData.map((d) => bumpEdge(d, chromeData, ieData, source)), ); } From 5ac2c81d991085fcaaf2de899b41d67678e3639c Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Tue, 17 May 2022 23:45:12 -0700 Subject: [PATCH 55/55] Change default to Chrome --- scripts/mirror.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/mirror.js b/scripts/mirror.js index 2e9aa2dc486792..7febadb005feb9 100644 --- a/scripts/mirror.js +++ b/scripts/mirror.js @@ -127,9 +127,6 @@ const getSource = (browser, forced_source) => { case 'safari_ios': source = 'safari'; break; - case 'edge': - source = 'chrome-ie'; - break; default: throw Error( `${browser} is a base browser and a "source" browser must be specified.`,