From 5023150307b5f110d945a6564e7917b6767aa500 Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Wed, 7 Dec 2022 12:45:20 +0200 Subject: [PATCH] Fix html transformer fn --- .../Challenges/rechallenge/transformers.js | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/client/src/templates/Challenges/rechallenge/transformers.js b/client/src/templates/Challenges/rechallenge/transformers.js index f04f0de5bfc37a..4abd8943a2eaaa 100644 --- a/client/src/templates/Challenges/rechallenge/transformers.js +++ b/client/src/templates/Challenges/rechallenge/transformers.js @@ -211,24 +211,16 @@ export const embedFilesInHtml = async function (challengeFiles) { const style = contentDocument.createElement('style'); style.classList.add('fcc-injected-styles'); style.innerHTML = stylesCss?.contents; - link.parentNode.replaceChild(style, link); - } else if (stylesCss?.contents) { - // automatic linking of style contents to html - const style = contentDocument.createElement('style'); - style.classList.add('fcc-injected-styles'); - style.innerHTML = stylesCss?.contents; - contentDocument.head.appendChild(style); + + link.parentNode.appendChild(style); + + link.removeAttribute('href'); + link.dataset.href = 'styles.css'; } if (script) { - const newScript = contentDocument.createElement('script'); - newScript.innerHTML = scriptJs?.contents; - script.parentNode.replaceChild(newScript, script); - } - if (indexJsx?.contents) { - // automatic linking of jsx to html - const newScript = contentDocument.createElement('script'); - newScript.innerHTML = indexJsx?.contents; - contentDocument.head.appendChild(newScript); + script.innerHTML = scriptJs?.contents; + script.removeAttribute('src'); + script.setAttribute('data-src', 'script.js'); } return { contents: documentElement.innerHTML