Skip to content

Commit

Permalink
revert PR of placeholder function as placeholder value is seen displa…
Browse files Browse the repository at this point in the history
…yed with additional nbsp text in locale product pages in stage (#2709)

Update utils.js
  • Loading branch information
suhjainadobe authored Aug 8, 2024
1 parent f36fea1 commit ccb9704
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions libs/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,27 +724,10 @@ async function decorateIcons(area, config) {
async function decoratePlaceholders(area, config) {
const el = area.querySelector('main') || area;
const regex = /{{(.*?)}}|%7B%7B(.*?)%7D%7D/g;
const walker = document.createTreeWalker(
el,
NodeFilter.SHOW_TEXT,
{
acceptNode(node) {
return regex.test(node.nodeValue) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
},
},
);
const nodes = [];
let node = walker.nextNode();
while (node !== null) {
nodes.push(node);
node = walker.nextNode();
}
if (!nodes.length) return;
const found = regex.test(el.innerHTML);
if (!found) return;
const { replaceText } = await import('../features/placeholders.js');
const replaceNodes = nodes.map(async (textNode) => {
textNode.nodeValue = await replaceText(textNode.nodeValue, config, regex);
});
await Promise.all(replaceNodes);
el.innerHTML = await replaceText(el.innerHTML, config, regex);
}

async function loadFooter() {
Expand Down

0 comments on commit ccb9704

Please sign in to comment.