Skip to content

Commit

Permalink
MWPW-161606 [MEP] Modify within modals with MEP (#3171)
Browse files Browse the repository at this point in the history
initial commit publish

Co-authored-by: viloria <viloria@adobe.com>
  • Loading branch information
vgoodric and ivanvatadobe authored Nov 8, 2024
1 parent 9435d4e commit 0b3c6b6
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions libs/blocks/fragment/fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,15 @@ const updateFragMap = (fragment, a, href) => {
}
};

const insertInlineFrag = (sections, a, relHref, mep, handleMepCommands) => {
const insertInlineFrag = (sections, a, relHref) => {
// Inline fragments only support one section, other sections are ignored
const fragChildren = [...sections[0].children];
if (a.parentElement.nodeName === 'DIV' && !a.parentElement.attributes.length) {
a.parentElement.replaceWith(...fragChildren);
} else {
a.replaceWith(...fragChildren);
}
fragChildren.forEach((child) => {
child.setAttribute('data-path', relHref);
if (handleMepCommands) mep.commands = handleMepCommands(mep.commands, child);
});
fragChildren.forEach((child) => child.setAttribute('data-path', relHref));
};

function replaceDotMedia(path, doc) {
Expand Down Expand Up @@ -132,16 +129,14 @@ export default async function init(a) {
const { updateFragDataProps } = await import('../../features/personalization/personalization.js');
updateFragDataProps(a, inline, sections, fragment);
}
let handleMepCommands = false;
if (mep?.commands?.length) {
const { handleCommands } = await import('../../features/personalization/personalization.js');
handleMepCommands = handleCommands;
handleCommands(mep?.commands, fragment, false, true);
}
if (inline) {
insertInlineFrag(sections, a, relHref, mep, handleMepCommands);
insertInlineFrag(sections, a, relHref, mep);
} else {
a.parentElement.replaceChild(fragment, a);
if (handleMepCommands) handleMepCommands(mep?.commands, fragment);
await loadArea(fragment);
}
}
Expand Down

0 comments on commit 0b3c6b6

Please sign in to comment.