mirror of https://github.com/sveltejs/svelte
feat: add unstate utility function (#9776)
* feat: add unstate utility function * Update packages/svelte/src/internal/client/proxy/proxy.js Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> * update docs * add class support * oops * lint * fix docs * remove symbol and class support --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> Co-authored-by: Rich Harris <richard.a.harris@gmail.com>pull/9791/head
parent
f1954d034b
commit
c7e626ebbb
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: add unstate utility function
|
@ -0,0 +1,12 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `<button>[{"a":0}]</button>`,
|
||||||
|
|
||||||
|
async test({ assert, target }) {
|
||||||
|
const btn = target.querySelector('button');
|
||||||
|
|
||||||
|
await btn?.click();
|
||||||
|
assert.htmlEqual(target.innerHTML, `<button>[{"a":0},{"a":1}]</button>`);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,7 @@
|
|||||||
|
<script>
|
||||||
|
import { unstate } from 'svelte';
|
||||||
|
|
||||||
|
let items = $state([{a: 0}]);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={() => items.push({a: items.length})}>{JSON.stringify(structuredClone(unstate(items)))}</button>
|
Loading…
Reference in new issue