Skip to content

Commit

Permalink
MWPW-157887 [MEP] HTML elements like body need to be recognized and h…
Browse files Browse the repository at this point in the history
…eader simplified selector rename (#2843)

* add more html els and change header to any header

* MWPW-157686 [MEP] Cannot spoof an experience that exists in manifest but not in Target (#2844)

Fix preview bug

---------

Co-authored-by: Mark Perry <[email protected]>
  • Loading branch information
vgoodric and markpadbe authored Sep 9, 2024
1 parent 8138b79 commit 38beea9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
9 changes: 5 additions & 4 deletions libs/features/personalization/personalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,13 @@ function modifySelectorTerm(termParam) {
'secondary-cta': 'em a',
'action-area': '*:has(> em a, > strong a)',
'any-marquee': '[class*="marquee"]',
header: ':is(h1, h2, h3, h4, h5, h6)',
'any-header': ':is(h1, h2, h3, h4, h5, h6)',
};
const otherSelectors = ['row', 'col'];
const htmlEls = ['main', 'div', 'a', 'p', 'strong', 'em', 'picture', 'source', 'img', 'h'];
const htmlEls = [
'html', 'body', 'header', 'footer', 'main',
'div', 'a', 'p', 'strong', 'em', 'picture', 'source', 'img', 'h',
];
const startTextMatch = term.match(/^[a-zA-Z/./-]*/);
const startText = startTextMatch ? startTextMatch[0].toLowerCase() : '';
const startTextPart1 = startText.split(/\.|:/)[0];
Expand Down Expand Up @@ -890,8 +893,6 @@ export function cleanAndSortManifestList(manifests) {
freshManifest = manifestObj[manifest.manifestPath];
}
freshManifest.name = fullManifest.name;
freshManifest.selectedVariantName = fullManifest.selectedVariantName;
freshManifest.selectedVariant = freshManifest.variants[freshManifest.selectedVariantName];
manifestObj[manifest.manifestPath] = freshManifest;
} else {
manifestObj[manifest.manifestPath] = manifest;
Expand Down
14 changes: 13 additions & 1 deletion test/features/personalization/modifyNonFragmentSelector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import { expect } from '@esm-bundle/chai';
import { modifyNonFragmentSelector } from '../../../libs/features/personalization/personalization.js';

const values = [
{
b: 'body > main > div',
a: 'body > main > div',
},
{
b: 'main header',
a: 'main header',
},
{
b: 'main footer',
a: 'main footer',
},
{
b: 'any-marquee action-area',
a: '[class*="marquee"] *:has(> em a, > strong a)',
Expand All @@ -23,7 +35,7 @@ const values = [
a: '.marquee.light:nth-child(2) h2',
},
{
b: 'marquee.light:nth-child(2) header',
b: 'marquee.light:nth-child(2) any-header',
a: '.marquee.light:nth-child(2) :is(h1, h2, h3, h4, h5, h6)',
},
{
Expand Down

0 comments on commit 38beea9

Please sign in to comment.