@@ -211,24 +211,16 @@ export const embedFilesInHtml = async function (challengeFiles) {
211
211
const style = contentDocument . createElement ( 'style' ) ;
212
212
style . classList . add ( 'fcc-injected-styles' ) ;
213
213
style . innerHTML = stylesCss ?. contents ;
214
- link . parentNode . replaceChild ( style , link ) ;
215
- } else if ( stylesCss ?. contents ) {
216
- // automatic linking of style contents to html
217
- const style = contentDocument . createElement ( 'style' ) ;
218
- style . classList . add ( 'fcc-injected-styles' ) ;
219
- style . innerHTML = stylesCss ?. contents ;
220
- contentDocument . head . appendChild ( style ) ;
214
+
215
+ link . parentNode . appendChild ( style ) ;
216
+
217
+ link . removeAttribute ( 'href' ) ;
218
+ link . dataset . href = 'styles.css' ;
221
219
}
222
220
if ( script ) {
223
- const newScript = contentDocument . createElement ( 'script' ) ;
224
- newScript . innerHTML = scriptJs ?. contents ;
225
- script . parentNode . replaceChild ( newScript , script ) ;
226
- }
227
- if ( indexJsx ?. contents ) {
228
- // automatic linking of jsx to html
229
- const newScript = contentDocument . createElement ( 'script' ) ;
230
- newScript . innerHTML = indexJsx ?. contents ;
231
- contentDocument . head . appendChild ( newScript ) ;
221
+ script . innerHTML = scriptJs ?. contents ;
222
+ script . removeAttribute ( 'src' ) ;
223
+ script . setAttribute ( 'data-src' , 'script.js' ) ;
232
224
}
233
225
return {
234
226
contents : documentElement . innerHTML
0 commit comments