-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't throw
bind_invalid_export
if there's also a bindable pro…
…p with the same name (#14813)
- Loading branch information
1 parent
cd1adbc
commit 72a6c72
Showing
5 changed files
with
64 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: don't throw `bind_invalid_export` if there's also a bindable prop with the same name |
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
9 changes: 9 additions & 0 deletions
9
packages/svelte/tests/runtime-runes/samples/bindable-prop-and-export/Component.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,9 @@ | ||
<script> | ||
let { open: is_open = $bindable() } = $props(); | ||
export function open(){ | ||
is_open = !is_open; | ||
} | ||
</script> | ||
|
||
<button onclick={open}>{is_open}</button> |
35 changes: 35 additions & 0 deletions
35
packages/svelte/tests/runtime-runes/samples/bindable-prop-and-export/_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,35 @@ | ||
import { ok, test } from '../../test'; | ||
import { flushSync } from 'svelte'; | ||
|
||
export default test({ | ||
compileOptions: { | ||
dev: true | ||
}, | ||
html: `<button>true</button><button>true</button><input type="checkbox" />`, | ||
ssrHtml: `<button>true</button><button>true</button><input type="checkbox" checked=""/>`, | ||
|
||
async test({ assert, target, instance }) { | ||
const [btn1, btn2] = target.querySelectorAll('button'); | ||
const input = target.querySelector('input'); | ||
flushSync(() => { | ||
btn1.click(); | ||
}); | ||
assert.equal(btn1.innerHTML, 'false'); | ||
assert.equal(btn2.innerHTML, 'false'); | ||
assert.equal(input?.checked, false); | ||
|
||
flushSync(() => { | ||
btn2.click(); | ||
}); | ||
assert.equal(btn1.innerHTML, 'true'); | ||
assert.equal(btn2.innerHTML, 'true'); | ||
assert.equal(input?.checked, true); | ||
|
||
flushSync(() => { | ||
input?.click(); | ||
}); | ||
assert.equal(btn1.innerHTML, 'false'); | ||
assert.equal(btn2.innerHTML, 'false'); | ||
assert.equal(input?.checked, false); | ||
} | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/svelte/tests/runtime-runes/samples/bindable-prop-and-export/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,14 @@ | ||
<script> | ||
import Component from "./Component.svelte"; | ||
let open = $state(true); | ||
let comp; | ||
</script> | ||
|
||
<Component bind:this={comp} bind:open /> | ||
|
||
<button onclick={()=>{ | ||
comp.open(); | ||
}}>{open}</button> | ||
|
||
<input type="checkbox" bind:checked={open} /> |