mirror of https://github.com/sveltejs/svelte
feat: fix accessors and support migration of accessors (#13456)
* feat: fix accessors and support migration of accessors * fix: exclude slots * fix: remove call to proxy for accessors props Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> * chore: add test for accessors * chore: fix lint --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>pull/13485/head
parent
dfe0138e0d
commit
c716329806
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: fix accessors and support migration of accessors
|
@ -0,0 +1,14 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
type $$Props = {
|
||||||
|
test: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export let count = 0;
|
||||||
|
export let stuff;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button>
|
||||||
|
<slot name="cool" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<svelte:options accessors immutable/>
|
@ -0,0 +1,29 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
test: string;
|
||||||
|
count?: number;
|
||||||
|
stuff: any;
|
||||||
|
cool?: import('svelte').Snippet;
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
test,
|
||||||
|
count = 0,
|
||||||
|
stuff,
|
||||||
|
cool
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
|
export {
|
||||||
|
test,
|
||||||
|
count,
|
||||||
|
stuff,
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button>
|
||||||
|
{@render cool?.()}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<svelte:options immutable/>
|
@ -0,0 +1,15 @@
|
|||||||
|
import { ok, test } from '../../test';
|
||||||
|
import { flushSync } from 'svelte';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `<p>0</p>`,
|
||||||
|
|
||||||
|
async test({ assert, target, instance }) {
|
||||||
|
const p = target.querySelector('p');
|
||||||
|
ok(p);
|
||||||
|
flushSync(() => {
|
||||||
|
instance.count++;
|
||||||
|
});
|
||||||
|
assert.equal(p.innerHTML, '1');
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,9 @@
|
|||||||
|
<script>
|
||||||
|
let { count=0 } = $props();
|
||||||
|
|
||||||
|
export {
|
||||||
|
count
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>{count}</p>
|
Loading…
Reference in new issue