From 7fe4330ca9da0e91418c05ffb0456dea0b2459dd Mon Sep 17 00:00:00 2001 From: Pascal Kuster Date: Wed, 25 Nov 2020 18:04:48 +0100 Subject: [PATCH] fix template script tag support #13270 --- lib/client-api/src/simulate-pageload.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/client-api/src/simulate-pageload.ts b/lib/client-api/src/simulate-pageload.ts index 274eaaecf406..488e33289b5e 100644 --- a/lib/client-api/src/simulate-pageload.ts +++ b/lib/client-api/src/simulate-pageload.ts @@ -82,15 +82,17 @@ export function simulatePageLoad($container: any) { const typeAttr = $script.getAttribute('type'); // only run script tags without the type attribute - // or with a javascript mime attribute value - if (!typeAttr || !runScriptTypes.includes(typeAttr)) { + // or with a javascript mime attribute value from the list + if (!typeAttr || runScriptTypes.includes(typeAttr)) { scriptsToExecute.push((callback: any) => insertScript($script, callback, $scriptsRoot)); } }); // insert the script tags sequentially // to preserve execution order - insertScriptsSequentially(scriptsToExecute, simulateDOMContentLoaded, undefined); + if (scriptsToExecute.length) { + insertScriptsSequentially(scriptsToExecute, simulateDOMContentLoaded, undefined); + } } else { simulateDOMContentLoaded(); }