From d80e92b5e8d0ea04cc5e55c5ba91b6be5898f337 Mon Sep 17 00:00:00 2001 From: Philipp Stracker Date: Mon, 7 Oct 2024 15:18:51 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Minor=20refactoring=20in=20boot.?= =?UTF-8?q?js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/ppcp-applepay/resources/js/boot.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/ppcp-applepay/resources/js/boot.js b/modules/ppcp-applepay/resources/js/boot.js index b1aa0b81d..c76635378 100644 --- a/modules/ppcp-applepay/resources/js/boot.js +++ b/modules/ppcp-applepay/resources/js/boot.js @@ -4,7 +4,7 @@ import ApplePayManager from './ApplepayManager'; import { setupButtonEvents } from '../../../ppcp-button/resources/js/modules/Helper/ButtonRefreshHelper'; ( function ( { buttonConfig, ppcpConfig } ) { - const bootstrap = function () { + function bootstrapPayButton() { if ( ! buttonConfig || ! ppcpConfig ) { return; } @@ -14,8 +14,12 @@ import { setupButtonEvents } from '../../../ppcp-button/resources/js/modules/Hel setupButtonEvents( function () { manager.reinit(); } ); - }; + } + function bootstrap() { + bootstrapPayButton(); + // Other Apple Pay bootstrapping could happen here. + } document.addEventListener( 'DOMContentLoaded', () => { if ( ! buttonConfig || ! ppcpConfig ) { @@ -29,13 +33,13 @@ import { setupButtonEvents } from '../../../ppcp-button/resources/js/modules/Hel return; } - const isMiniCart = ppcpConfig.mini_cart_buttons_enabled; - const isButton = + const usedInMiniCart = ppcpConfig.mini_cart_buttons_enabled; + const pageHasButton = null !== document.getElementById( buttonConfig.button.wrapper ); // If button wrapper is not present then there is no need to load the scripts. // minicart loads later? - if ( ! isMiniCart && ! isButton ) { + if ( ! usedInMiniCart && ! pageHasButton ) { return; }