diff --git a/libs/blocks/global-navigation/utilities/utilities.js b/libs/blocks/global-navigation/utilities/utilities.js index 874150dfbe..14ebb1ed25 100644 --- a/libs/blocks/global-navigation/utilities/utilities.js +++ b/libs/blocks/global-navigation/utilities/utilities.js @@ -340,9 +340,9 @@ export async function fetchAndProcessPlainHtml({ url, shouldDecorateLinks = true if (mepFragment?.targetManifestId) body.dataset.adobeTargetTestid = mepFragment.targetManifestId; const commands = mepGnav?.commands; if (commands?.length) { - const { handleCommands, deleteMarkedEls } = await import('../../../features/personalization/personalization.js'); + /* c8 ignore next 3 */ + const { handleCommands } = await import('../../../features/personalization/personalization.js'); handleCommands(commands, body, true, true); - deleteMarkedEls(body); } const inlineFrags = [...body.querySelectorAll('a[href*="#_inline"]')]; if (inlineFrags.length) { diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index 7cf87b0469..8fa083011b 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -6,6 +6,7 @@ import { getFederatedUrl } from '../../utils/federated.js'; /* c8 ignore start */ const PHONE_SIZE = window.screen.width < 550 || window.screen.height < 550; +const safariIpad = navigator.userAgent.includes('Macintosh') && navigator.maxTouchPoints > 1; export const PERSONALIZATION_TAGS = { all: () => true, chrome: () => navigator.userAgent.includes('Chrome') && !navigator.userAgent.includes('Edg'), @@ -13,10 +14,12 @@ export const PERSONALIZATION_TAGS = { safari: () => navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome'), edge: () => navigator.userAgent.includes('Edg'), android: () => navigator.userAgent.includes('Android'), - ios: () => /iPad|iPhone|iPod/.test(navigator.userAgent), + ios: () => /iPad|iPhone|iPod/.test(navigator.userAgent) || safariIpad, windows: () => navigator.userAgent.includes('Windows'), - mac: () => navigator.userAgent.includes('Macintosh'), - 'mobile-device': () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Touch/i.test(navigator.userAgent), + mac: () => navigator.userAgent.includes('Macintosh') && !safariIpad, + 'mobile-device': () => safariIpad + || /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Touch/i + .test(navigator.userAgent), phone: () => PERSONALIZATION_TAGS['mobile-device']() && PHONE_SIZE, tablet: () => PERSONALIZATION_TAGS['mobile-device']() && !PHONE_SIZE, desktop: () => !PERSONALIZATION_TAGS['mobile-device'](), @@ -495,7 +498,17 @@ export const updateFragDataProps = (a, inline, sections, fragment) => { } }; -export function handleCommands(commands, rootEl, forceInline = false, forceRootEl = false) { +export const deleteMarkedEls = (rootEl = document) => { + [...rootEl.querySelectorAll(`.${CLASS_EL_DELETE}`)] + .forEach((el) => el.remove()); +}; + +export function handleCommands( + commands, + rootEl = document, + forceInline = false, + forceRootEl = false, +) { const section1 = document.querySelector('main > div'); commands.forEach((cmd) => { const { action, content, selector } = cmd; @@ -529,6 +542,7 @@ export function handleCommands(commands, rootEl, forceInline = false, forceRootE cmd.completed = true; } }); + deleteMarkedEls(rootEl); return commands.filter((cmd) => !cmd.completed && cmd.selectorType !== IN_BLOCK_SELECTOR_PREFIX); } @@ -887,11 +901,6 @@ export async function getManifestConfig(info = {}, variantOverride = false) { return manifestConfig; } -export const deleteMarkedEls = (rootEl = document) => { - [...rootEl.querySelectorAll(`.${CLASS_EL_DELETE}`)] - .forEach((el) => el.remove()); -}; - const normalizeFragPaths = ({ selector, val, action, manifestId, targetManifestId }) => ({ selector: normalizePath(selector), val: normalizePath(val), @@ -1047,7 +1056,6 @@ export async function applyPers(manifests) { } config.mep.commands = handleCommands(config.mep.commands); - deleteMarkedEls(); const pznList = results.filter((r) => (r.experiment?.manifestType === TRACKED_MANIFEST_TYPE)); if (!pznList.length) return;