mirror of https://github.com/sveltejs/svelte
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 <simon.holthausen@vercel.com>pull/13406/head
parent
b73052f590
commit
9627426f7f
@ -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>`
|
||||
);
|
||||
}
|
||||
});
|
@ -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>
|
Loading…
Reference in new issue