Skip to content

Commit

Permalink
Merge branch 'stage' into MWPW-158083
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinrivero authored Dec 16, 2024
2 parents 96d43b1 + b38c7cf commit e7c9b80
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions acrobat/blocks/dc-converter-widget/dc-converter-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export default async function init(element) {
const preRenderDropZone = !isLimitExhausted && !isRedirection;

const INLINE_SNIPPET = widget.querySelector(':scope > section#edge-snippet');
if (INLINE_SNIPPET) {
if (INLINE_SNIPPET && INLINE_SNIPPET.childNodes.length > 0) {
if (!isLimitExhausted) {
widgetContainer.dataset.rendered = 'true';
widgetContainer.appendChild(...INLINE_SNIPPET.childNodes);
Expand All @@ -247,11 +247,16 @@ export default async function init(element) {
case 200: {
const template = await response.text();
if (!('rendered' in widgetContainer.dataset)) {
widgetContainer.dataset.rendered = 'true';
const doc = new DOMParser().parseFromString(template, 'text/html');
document.head.appendChild(doc.head.getElementsByTagName('Style')[0]);
widgetContainer.appendChild(doc.body.firstElementChild);
performance.mark('milo-insert-snippet');
try {
widgetContainer.dataset.rendered = 'true';
const doc = new DOMParser().parseFromString(template, 'text/html');
document.head.appendChild(doc.head.getElementsByTagName('Style')[0]);
widgetContainer.appendChild(doc.body.firstElementChild);
performance.mark('milo-insert-snippet');
} catch (e) {
// eslint-disable-next-line no-console
console.error(`Error: ${e.message}`);
}
}
break;
}
Expand Down

0 comments on commit e7c9b80

Please sign in to comment.