mirror of https://github.com/sveltejs/svelte
fix: ensure rest props access on hoisted event handlers works (#12298)
If an even handler is hoisted and said event handler access rest props, we can't be sure whether or not it will access it via `$$props` (optimized) or via `rest()` - therefore we add both as params in this edge case fixes #12279pull/12304/head
parent
80263770f1
commit
bc32b7c828
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: ensure rest props access on hoisted event handlers works
|
@ -0,0 +1,14 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
mode: ['client'],
|
||||||
|
test({ assert, target, logs }) {
|
||||||
|
const btn = target.querySelector('button');
|
||||||
|
|
||||||
|
btn?.click();
|
||||||
|
flushSync();
|
||||||
|
|
||||||
|
assert.deepEqual(logs, ['worked']);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
let { label, ...rest } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => rest?.onclick()}>{label}</button>
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
import Child from './child.svelte';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Child label="click me" onclick={() => console.log('worked')} />
|
Loading…
Reference in new issue