diff --git a/dist/aem.js b/dist/aem.js index 9b83cf6..762e043 100644 --- a/dist/aem.js +++ b/dist/aem.js @@ -154,18 +154,9 @@ function setup() { window.hlx = window.hlx || {}; window.hlx.RUM_MASK_URL = 'full'; window.hlx.RUM_MANUAL_ENHANCE = true; - window.hlx.codeBasePath = ''; window.hlx.lighthouse = new URLSearchParams(window.location.search).get('lighthouse') === 'on'; - const scriptEl = document.querySelector('script[src$="/scripts/scripts.js"]'); - if (scriptEl) { - try { - [window.hlx.codeBasePath] = new URL(scriptEl.src).pathname.split('/scripts/scripts.js'); - } catch (error) { - // eslint-disable-next-line no-console - console.log(error); - } - } + [window.hlx.codeBasePath] = new URL(import.meta.url).pathname.split('/scripts/'); } /** @@ -462,6 +453,7 @@ function decorateButtons(element) { * @param {string} [alt] alt text to be added to icon */ function decorateIcon(span, prefix = '', alt = '') { + if (span.hasChildNodes()) return; // already decorated const iconName = Array.from(span.classList) .find((c) => c.startsWith('icon-')) .substring(5); diff --git a/src/setup.js b/src/setup.js index 04177a3..a366f81 100644 --- a/src/setup.js +++ b/src/setup.js @@ -19,19 +19,9 @@ export function setup() { window.hlx = window.hlx || {}; window.hlx.RUM_MASK_URL = 'full'; window.hlx.RUM_MANUAL_ENHANCE = true; - window.hlx.codeBasePath = ''; window.hlx.lighthouse = new URLSearchParams(window.location.search).get('lighthouse') === 'on'; - const scriptEl = document.querySelector('script[src$="/scripts/scripts.js"]'); - if (scriptEl) { - try { - [window.hlx.codeBasePath] = new URL(scriptEl.src).pathname.split('/scripts/scripts.js'); - /* c8 ignore next 4 */ - } catch (error) { - // eslint-disable-next-line no-console - console.log(error); - } - } + [window.hlx.codeBasePath] = new URL(import.meta.url).pathname.split('/scripts/'); } /** diff --git a/test/setup/setup.test.html b/test/setup/setup.test.html index 586a720..b3368d5 100644 --- a/test/setup/setup.test.html +++ b/test/setup/setup.test.html @@ -1,8 +1,5 @@ -
- -