-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure single script and scripts in loops execute properly (#13386)
- add a comment to lone script tags to ensure there's always a parent so we can synchronously call the replace function - always call the replace function, not just on the first call fixes #13378 --------- Co-authored-by: Simon Holthausen <[email protected]>
- Loading branch information
1 parent
b73052f
commit 9627426
Showing
4 changed files
with
55 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/svelte/tests/runtime-browser/samples/head-scripts/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { test } from '../../assert'; | ||
|
||
export default test({ | ||
mode: ['client'], | ||
async test({ assert, window }) { | ||
// wait the script to load (maybe there a better way) | ||
await new Promise((resolve) => setTimeout(resolve, 1)); | ||
assert.htmlEqual( | ||
window.document.body.innerHTML, | ||
`<main><b id="r1">1</b><b id="r2">2</b><b id="r3">3</b></main>` | ||
); | ||
} | ||
}); |
16 changes: 16 additions & 0 deletions
16
packages/svelte/tests/runtime-browser/samples/head-scripts/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<script> | ||
function jssrc(src) { | ||
return 'data:text/javascript;base64, ' + btoa(src); | ||
} | ||
const scriptSrcs = [ 1, 2, 3 ] | ||
.map(n => jssrc(`document.getElementById('r${n}').innerText = '${n}';`)); | ||
</script> | ||
|
||
<svelte:head> | ||
{#each scriptSrcs as src} | ||
<script src={src} async defer></script> | ||
{/each} | ||
</svelte:head> | ||
|
||
<b id="r1">?</b><b id="r2">?</b><b id="r3">?</b> |