From c855052d406fcf0fa0d46ed56a4c3ce1eadbacb1 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Wed, 2 Mar 2022 11:21:29 +0000 Subject: [PATCH 1/2] Ignore styles which no longer apply --- .../PageBuilder/view/adminhtml/web/js/stage-builder.js | 4 +++- .../PageBuilder/view/adminhtml/web/ts/js/stage-builder.ts | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/PageBuilder/view/adminhtml/web/js/stage-builder.js b/app/code/Magento/PageBuilder/view/adminhtml/web/js/stage-builder.js index b73292469b7..fc44f50f172 100644 --- a/app/code/Magento/PageBuilder/view/adminhtml/web/js/stage-builder.js +++ b/app/code/Magento/PageBuilder/view/adminhtml/web/js/stage-builder.js @@ -49,6 +49,8 @@ define(["mage/translate", "Magento_PageBuilder/js/events", "Magento_Ui/js/modal/ _.each(styles, function (stylesArray, selector) { var element = document.querySelector(selector); + if (!element) return; + _.each(stylesArray, function (style) { element.setAttribute("data-" + name + "-style", element.getAttribute("data-" + name + "-style") ? element.getAttribute("data-" + name + "-style") + style.cssText : style.cssText); }); @@ -331,4 +333,4 @@ define(["mage/translate", "Magento_PageBuilder/js/events", "Magento_Ui/js/modal/ return build; }); -//# sourceMappingURL=stage-builder.js.map \ No newline at end of file +//# sourceMappingURL=stage-builder.js.map diff --git a/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/stage-builder.ts b/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/stage-builder.ts index 01c61e09ba5..49fa67c12d0 100644 --- a/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/stage-builder.ts +++ b/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/stage-builder.ts @@ -60,6 +60,8 @@ function convertToInlineStyles(document: Document): void { _.each(styles, (stylesArray: CSSStyleDeclaration[], selector: string) => { const element: HTMLElement = document.querySelector(selector); + if (!element) return; + _.each(stylesArray, (style: CSSStyleDeclaration) => { element.setAttribute( `data-${name}-style`, From f762873a923ed18cb8a6b75c5ad71d0d2e12b845 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Fri, 24 Jun 2022 10:42:31 +0100 Subject: [PATCH 2/2] Add braces to appease static analysis tool --- .../PageBuilder/view/adminhtml/web/js/stage-builder.js | 4 +++- .../PageBuilder/view/adminhtml/web/ts/js/stage-builder.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/PageBuilder/view/adminhtml/web/js/stage-builder.js b/app/code/Magento/PageBuilder/view/adminhtml/web/js/stage-builder.js index fc44f50f172..a34133d007c 100644 --- a/app/code/Magento/PageBuilder/view/adminhtml/web/js/stage-builder.js +++ b/app/code/Magento/PageBuilder/view/adminhtml/web/js/stage-builder.js @@ -49,7 +49,9 @@ define(["mage/translate", "Magento_PageBuilder/js/events", "Magento_Ui/js/modal/ _.each(styles, function (stylesArray, selector) { var element = document.querySelector(selector); - if (!element) return; + if (!element) { + return; + } _.each(stylesArray, function (style) { element.setAttribute("data-" + name + "-style", element.getAttribute("data-" + name + "-style") ? element.getAttribute("data-" + name + "-style") + style.cssText : style.cssText); diff --git a/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/stage-builder.ts b/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/stage-builder.ts index 49fa67c12d0..e9322ec6ea7 100644 --- a/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/stage-builder.ts +++ b/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/stage-builder.ts @@ -60,7 +60,9 @@ function convertToInlineStyles(document: Document): void { _.each(styles, (stylesArray: CSSStyleDeclaration[], selector: string) => { const element: HTMLElement = document.querySelector(selector); - if (!element) return; + if (!element) { + return; + } _.each(stylesArray, (style: CSSStyleDeclaration) => { element.setAttribute(