-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow runelike writable as prop (#11768)
Fixes #11742
- Loading branch information
1 parent
d856c50
commit 9084f17
Showing
7 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"svelte": patch | ||
--- | ||
|
||
fix: allow runelike writable as prop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/svelte/tests/runtime-runes/samples/store-from-props-runelike/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
test({ assert, target, ok }) { | ||
const button = target.querySelector('button'); | ||
|
||
flushSync(() => { | ||
button?.click(); | ||
}); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<button>1</button> | ||
` | ||
); | ||
} | ||
}); |
5 changes: 5 additions & 0 deletions
5
packages/svelte/tests/runtime-runes/samples/store-from-props-runelike/child.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
let { state } = $props(); | ||
</script> | ||
|
||
<button onclick={()=> $state++}>{$state}</button> |
8 changes: 8 additions & 0 deletions
8
packages/svelte/tests/runtime-runes/samples/store-from-props-runelike/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<svelte:options runes /> | ||
<script> | ||
import { writable } from "svelte/store"; | ||
import Child from "./child.svelte"; | ||
const state = writable(0); | ||
</script> | ||
|
||
<Child {state} /> |
6 changes: 6 additions & 0 deletions
6
packages/svelte/tests/validator/samples/store-rune-conflic-from-props/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<script> | ||
let { state } = $props(); | ||
let x = $state(); | ||
</script> | ||
|
||
{$state} |
14 changes: 14 additions & 0 deletions
14
packages/svelte/tests/validator/samples/store-rune-conflic-from-props/warnings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[ | ||
{ | ||
"code": "store_rune_conflict", | ||
"message": "It looks like you're using the `$state` rune, but there is a local binding called `state`. Referencing a local variable with a `$` prefix will create a store subscription. Please rename `state` to avoid the ambiguity", | ||
"start": { | ||
"line": 3, | ||
"column": 9 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 15 | ||
} | ||
} | ||
] |