From 9c44373b5cc71d3d979a5cbe152be04f515afec9 Mon Sep 17 00:00:00 2001 From: Adrian Date: Tue, 2 Jul 2024 11:30:42 +0300 Subject: [PATCH] fix(pie-loader): add onload and scripturl instead of content PD-3907 --- src/demo/passage.html | 105 ++++++++++++++++++++++++++++++++++++++++++ src/pie-loader.ts | 8 +--- 2 files changed, 107 insertions(+), 6 deletions(-) create mode 100644 src/demo/passage.html diff --git a/src/demo/passage.html b/src/demo/passage.html new file mode 100644 index 0000000..4cd8dc4 --- /dev/null +++ b/src/demo/passage.html @@ -0,0 +1,105 @@ + + + + + + Item With Stimulus + + + + +
+

render stimulus

+ +
+ + + + + diff --git a/src/pie-loader.ts b/src/pie-loader.ts index 7aaecbd..b12f9f6 100644 --- a/src/pie-loader.ts +++ b/src/pie-loader.ts @@ -300,13 +300,9 @@ export class PieLoader { // if the request is successful inject the response as a script tag // to avoid doing the same call twice if (response.status === 200) { - script.textContent = await response.text(); - script.type = 'application/javascript' + script.onload = onloadFn; + script.src = scriptUrl; head.appendChild(script); - - setTimeout(() => { - onloadFn(); - }, 100); } else { console.error("Failed to load script, status code:", response.status); }