mirror of https://github.com/sveltejs/svelte
breaking: robustify interop of exports and props (#11064)
- don't throw a dev time error when binding to an export (fixes #11008) - remove bindings that are for component exports - throw an error when using a component export with the same name as a propertypull/11072/head
parent
452749494e
commit
a9e15bdf2d
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
breaking: robustify interop of exports and props in runes mode
|
@ -0,0 +1,8 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
error: {
|
||||
code: 'conflicting-property-name',
|
||||
message: 'Cannot have a property and a component export with the same name'
|
||||
}
|
||||
});
|
@ -0,0 +1,4 @@
|
||||
<script>
|
||||
let { x: y } = $props();
|
||||
export function x() {}
|
||||
</script>
|
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
let { ...rest } = $props();
|
||||
let count = $state(0);
|
||||
export function increment() {
|
||||
count++;
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- test that the binding isn't inside rest -->
|
||||
{Object.keys(rest).length}
|
||||
|
||||
{count}
|
@ -0,0 +1,17 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
compileOptions: {
|
||||
dev: true // to ensure we don't throw a false-positive "cannot bind to this" error
|
||||
},
|
||||
html: `0 0 <button>increment</button>`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
btn?.click();
|
||||
await Promise.resolve();
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `0 1 <button>increment</button>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import Counter from './Counter.svelte';
|
||||
let increment;
|
||||
</script>
|
||||
|
||||
<Counter bind:increment={increment} />
|
||||
<button onclick={increment}>increment</button>
|
Loading…
Reference in new issue