mirror of https://github.com/sveltejs/svelte
feat: add $state.is rune (#11613)
* feat: add $state.is rune * fix type * tweak docs * may as well update the test case to match the docs --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/11621/head
parent
1087e6fb54
commit
f488a6e84a
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
feat: add $state.is rune
|
@ -0,0 +1,7 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, logs }) {
|
||||
assert.deepEqual(logs, [false, true]);
|
||||
}
|
||||
});
|
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
/** @type {{ bar?: any }}*/
|
||||
let foo = $state({});
|
||||
let bar = {};
|
||||
|
||||
foo.bar = bar;
|
||||
|
||||
console.log(foo.bar === bar); // false because of the $state proxy
|
||||
console.log($state.is(foo.bar, bar)); // true
|
||||
</script>
|
Loading…
Reference in new issue