mirror of https://github.com/sveltejs/svelte
fix: store from props hoist wrong param (#11367)
Fixes #11355 --------- Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>pull/11369/head
parent
68071f7c06
commit
c7bdef595b
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: ensure store from props is hoisted correctly
|
@ -0,0 +1,18 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
compileOptions: {
|
||||
dev: true
|
||||
},
|
||||
async test({ assert, target }) {
|
||||
const button = target.querySelector('button');
|
||||
await button?.click();
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>1</button>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
const { attrs } = $props();
|
||||
function increment() {
|
||||
$attrs.count++;
|
||||
}
|
||||
</script>
|
||||
|
||||
<button onclick={increment}>{$attrs.count}</button>
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import { writable } from "svelte/store";
|
||||
import Child from "./child.svelte";
|
||||
const attrs = writable({ count: 0 });
|
||||
</script>
|
||||
|
||||
<Child {attrs} />
|
Loading…
Reference in new issue