mirror of https://github.com/sveltejs/svelte
bindable-prop-and-export
parent
1d773ef3a4
commit
e75693e6e6
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: don't throw `bind_invalid_export` if there's also a bindable prop with the same name
|
@ -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>
|
@ -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);
|
||||
}
|
||||
});
|
@ -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} />
|
Loading…
Reference in new issue