From 1ee5cbc4102ecf5d619ce0b9bca245e2ee224aab Mon Sep 17 00:00:00 2001 From: Andrei Oprea Date: Tue, 8 Sep 2020 13:31:04 +0000 Subject: [PATCH] Bug 1661671 - Add plugin to support optional chaining operator in unit tests r=k88hudson Differential Revision: https://phabricator.services.mozilla.com/D88581 --- .../components/newtab/aboutwelcome/AboutWelcomeChild.jsm | 2 +- .../newtab/aboutwelcome/content/aboutwelcome.bundle.js | 4 ++-- .../newtab/content-src/aboutwelcome/aboutwelcome.jsx | 4 ++-- browser/components/newtab/lib/ASRouter.jsm | 6 +----- browser/components/newtab/webpack.system-addon.config.js | 1 + 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/browser/components/newtab/aboutwelcome/AboutWelcomeChild.jsm b/browser/components/newtab/aboutwelcome/AboutWelcomeChild.jsm index 0794f877c174..b77d2dbc347d 100644 --- a/browser/components/newtab/aboutwelcome/AboutWelcomeChild.jsm +++ b/browser/components/newtab/aboutwelcome/AboutWelcomeChild.jsm @@ -238,7 +238,7 @@ class AboutWelcomeChild extends JSWindowActorChild { Cu.reportError(e); } - if (experimentData && experimentData.slug) { + if (experimentData?.slug) { log.debug( `Loading about:welcome with experiment: ${experimentData.slug}` ); diff --git a/browser/components/newtab/aboutwelcome/content/aboutwelcome.bundle.js b/browser/components/newtab/aboutwelcome/content/aboutwelcome.bundle.js index 124ac3e7cc42..1edc65cc6c3d 100644 --- a/browser/components/newtab/aboutwelcome/content/aboutwelcome.bundle.js +++ b/browser/components/newtab/aboutwelcome/content/aboutwelcome.bundle.js @@ -224,9 +224,9 @@ async function mount() { slug, branch } = await window.AWGetStartupData(); - let settings = branch && branch.feature ? branch.feature.value : {}; + let settings = (branch === null || branch === void 0 ? void 0 : branch.feature) ? branch.feature.value : {}; - if (!(branch && branch.feature)) { + if (!(branch === null || branch === void 0 ? void 0 : branch.feature)) { // Check for override content in pref browser.aboutwelcome.overrideContent settings = await window.AWGetMultiStageScreens(); } diff --git a/browser/components/newtab/content-src/aboutwelcome/aboutwelcome.jsx b/browser/components/newtab/content-src/aboutwelcome/aboutwelcome.jsx index 2f6429505a96..460d04b922c8 100644 --- a/browser/components/newtab/content-src/aboutwelcome/aboutwelcome.jsx +++ b/browser/components/newtab/content-src/aboutwelcome/aboutwelcome.jsx @@ -117,9 +117,9 @@ function ComputeMessageId(experimentId, branchId, settings) { async function mount() { const { slug, branch } = await window.AWGetStartupData(); - let settings = branch && branch.feature ? branch.feature.value : {}; + let settings = branch?.feature ? branch.feature.value : {}; - if (!(branch && branch.feature)) { + if (!branch?.feature) { // Check for override content in pref browser.aboutwelcome.overrideContent settings = await window.AWGetMultiStageScreens(); } diff --git a/browser/components/newtab/lib/ASRouter.jsm b/browser/components/newtab/lib/ASRouter.jsm index e167c7775dec..a368d6f8c923 100644 --- a/browser/components/newtab/lib/ASRouter.jsm +++ b/browser/components/newtab/lib/ASRouter.jsm @@ -362,11 +362,7 @@ const MessageLoaderUtils = { continue; } - if ( - experimentData && - experimentData.branch && - experimentData.branch.feature - ) { + if (experimentData?.branch?.feature) { experiments.push(experimentData.branch.feature.value); if (!REACH_EVENT_GROUPS.includes(featureId)) { diff --git a/browser/components/newtab/webpack.system-addon.config.js b/browser/components/newtab/webpack.system-addon.config.js index 96ea08139af6..b510a64229b0 100644 --- a/browser/components/newtab/webpack.system-addon.config.js +++ b/browser/components/newtab/webpack.system-addon.config.js @@ -33,6 +33,7 @@ module.exports = (env = {}) => ({ loader: "babel-loader", options: { presets: ["@babel/preset-react"], + plugins: ["@babel/plugin-proposal-optional-chaining"], }, }, {