mirror of https://github.com/sveltejs/svelte
fix: scope SSR boundary failed snippets to their boundary (#18593)
Each `<svelte:boundary>` with:
```svelte
{#snippet failed(error)}
...
{/snippet}
```
generated a function named failed. Sibling boundaries placed both
functions in the same SSR scope:
```js
{
function failed() {}
function failed() {} // Identifier `failed` has already been declared
}
```
Resulting in a `[PARSE_ERROR] Identifier `failed` has already been
declared` error during build time.
A let declaration such as `{const x = 0}` can create a nested lexical
block, exposing the collision.
The fix gives each boundary its own scope:
```js
{
function failed() {}
$$renderer.boundary({ failed }, ...);
}
{
function failed() {}
$$renderer.boundary({ failed }, ...);
}
``
pull/18680/merge
parent
f4918d86f3
commit
38ef714f1a
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: scope SSR boundary failed snippets to their boundary
|
||||
@ -0,0 +1 @@
|
||||
<div></div>
|
||||
@ -0,0 +1,11 @@
|
||||
<div>
|
||||
{const x = 0}
|
||||
|
||||
<svelte:boundary>
|
||||
{#snippet failed()}{/snippet}
|
||||
</svelte:boundary>
|
||||
|
||||
<svelte:boundary>
|
||||
{#snippet failed()}{/snippet}
|
||||
</svelte:boundary>
|
||||
</div>
|
||||
Loading…
Reference in new issue