mirror of https://github.com/sveltejs/svelte
fix: treat spread elements the same as call expressions (#14488)
parent
9fcfd7f0d1
commit
fe15ad4ae8
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: treat spread elements the same as call expressions
|
@ -0,0 +1,16 @@
|
||||
/** @import { SpreadElement } from 'estree' */
|
||||
/** @import { Context } from '../types' */
|
||||
|
||||
/**
|
||||
* @param {SpreadElement} node
|
||||
* @param {Context} context
|
||||
*/
|
||||
export function SpreadElement(node, context) {
|
||||
if (context.state.expression) {
|
||||
// treat e.g. `[...x]` the same as `[...x.values()]`
|
||||
context.state.expression.has_call = true;
|
||||
context.state.expression.has_state = true;
|
||||
}
|
||||
|
||||
context.next();
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
let { numbers } = $props();
|
||||
</script>
|
||||
|
||||
{numbers.join(', ')}
|
@ -0,0 +1,13 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: '<button>+1</button> 0, 1, 2',
|
||||
|
||||
test({ target, assert }) {
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
flushSync(() => btn?.click());
|
||||
assert.htmlEqual(target.innerHTML, '<button>+1</button> 0, 1, 2, 3');
|
||||
}
|
||||
});
|
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
import { SvelteSet } from 'svelte/reactivity';
|
||||
import Child from './Child.svelte';
|
||||
|
||||
const numbers = new SvelteSet([0, 1, 2]);
|
||||
</script>
|
||||
|
||||
<button onclick={() => numbers.add(numbers.size)}>+1</button>
|
||||
|
||||
<Child numbers={[...numbers]} />
|
Loading…
Reference in new issue