Skip to content

Commit

Permalink
initial commit publish
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvatadobe committed Nov 5, 2024
1 parent 38504d5 commit 98e7685
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 98e7685

Please sign in to comment.