Skip to content

Commit ec8a029

Browse files
authored
fix: skip is_standalone optimisation for dynamic components (#12767)
* fix: skip `is_standalone` optimisation for dynamic components * changeset
1 parent 60148d3 commit ec8a029

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

.changeset/nice-bottles-greet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: skip `is_standalone` optimisation for dynamic components

packages/svelte/src/compiler/phases/3-transform/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ export function clean_nodes(
283283
((first.type === 'RenderTag' && !first.metadata.dynamic) ||
284284
(first.type === 'Component' &&
285285
!state.options.hmr &&
286+
!first.metadata.dynamic &&
286287
!first.attributes.some(
287288
(attribute) => attribute.type === 'Attribute' && attribute.name.startsWith('--')
288289
))),
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
let { id } = $props();
3+
</script>
4+
5+
<span>{id}</span>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { flushSync } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
html: `<button>flip</button> <span>0</span><span>1</span><span>2</span>`,
6+
7+
async test({ assert, target }) {
8+
const button = target.querySelector('button');
9+
10+
flushSync(() => button?.click());
11+
assert.htmlEqual(
12+
target.innerHTML,
13+
`<button>flip</button> <span>2</span><span>1</span><span>0</span>`
14+
);
15+
}
16+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script>
2+
import Row from './Row.svelte';
3+
4+
const items = $state([{ id: 0 }, { id: 1 }, { id: 2 }]);
5+
6+
const Table = { Row };
7+
</script>
8+
9+
<button onclick={() => items.reverse()}> flip </button>
10+
11+
{#each items as item (item.id)}
12+
<Table.Row id={item.id} />
13+
{/each}

0 commit comments

Comments
 (0)