fix: skip `is_standalone` optimisation for dynamic components (#12767)

* fix: skip `is_standalone` optimisation for dynamic components

* changeset
pull/12750/head
Rich Harris 3 months ago committed by GitHub
parent 60148d3352
commit ec8a029db4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: skip `is_standalone` optimisation for dynamic components

@ -283,6 +283,7 @@ export function clean_nodes(
((first.type === 'RenderTag' && !first.metadata.dynamic) ||
(first.type === 'Component' &&
!state.options.hmr &&
!first.metadata.dynamic &&
!first.attributes.some(
(attribute) => attribute.type === 'Attribute' && attribute.name.startsWith('--')
))),

@ -0,0 +1,5 @@
<script>
let { id } = $props();
</script>
<span>{id}</span>

@ -0,0 +1,16 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
html: `<button>flip</button> <span>0</span><span>1</span><span>2</span>`,
async test({ assert, target }) {
const button = target.querySelector('button');
flushSync(() => button?.click());
assert.htmlEqual(
target.innerHTML,
`<button>flip</button> <span>2</span><span>1</span><span>0</span>`
);
}
});

@ -0,0 +1,13 @@
<script>
import Row from './Row.svelte';
const items = $state([{ id: 0 }, { id: 1 }, { id: 2 }]);
const Table = { Row };
</script>
<button onclick={() => items.reverse()}> flip </button>
{#each items as item (item.id)}
<Table.Row id={item.id} />
{/each}
Loading…
Cancel
Save