mirror of https://github.com/sveltejs/svelte
fix: ensure inner script tags are properly removed (#13152)
We have a `run_scripts` function which is invoked in case a template block contains a script tag, and that function replaces the script tags (so that they actually run). If such a script tag is first or last in the template, the replacement is not picked up by our `node.first_node/last_node` logic anymore, and so it contains a stale tag. That means on cleanup the remove logic fails. In the case of the referenced issue, it just runs past the script tag till the very end of the head, removing the just added style tag from the new page. Fixes #13086pull/13158/head
parent
53a90fb8c7
commit
c372dd864d
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: ensure inner script tags are properly removed
|
@ -1,4 +1,11 @@
|
|||||||
<div></div>
|
<script lang="ts">
|
||||||
{#if true}
|
let visible = $state(true);
|
||||||
<script>document.body.innerHTML = 'this should be executed'</script>
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => (visible = false)}>hide</button>
|
||||||
|
{#if visible}
|
||||||
|
<script>
|
||||||
|
document.body.querySelector('.after').innerHTML = 'this should be executed';
|
||||||
|
</script>
|
||||||
{/if}
|
{/if}
|
||||||
|
<div class="after">after</div>
|
||||||
|
Loading…
Reference in new issue