mirror of https://github.com/sveltejs/svelte
parent
5eb8641ac7
commit
832f8deeec
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"svelte": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: ensure frozen objects in state are correctly skipped
|
@ -0,0 +1,7 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
test({ assert, target }) {
|
||||||
|
assert.htmlEqual(target.innerHTML, `<input type="text"><span>hello</span>`);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,34 @@
|
|||||||
|
<script>
|
||||||
|
const libFreezesObjects = true
|
||||||
|
|
||||||
|
function someLibFunctionCreatingFroozenObject(value) {
|
||||||
|
if(libFreezesObjects) {
|
||||||
|
return Object.freeze({inner: value})
|
||||||
|
} else {
|
||||||
|
return {inner: value}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function someLibFunctionReturningInner(wrapped) {
|
||||||
|
return wrapped.inner
|
||||||
|
}
|
||||||
|
|
||||||
|
function atom(init = null) {
|
||||||
|
let el = $state({value: someLibFunctionCreatingFroozenObject(init)})
|
||||||
|
|
||||||
|
return {
|
||||||
|
get value() {
|
||||||
|
return someLibFunctionReturningInner(el.value)
|
||||||
|
},
|
||||||
|
set value(v) {
|
||||||
|
el.value = someLibFunctionCreatingFroozenObject(v)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let val = atom('hello')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<input type="text" bind:value={val.value} />
|
||||||
|
|
||||||
|
<span>{val.value}</span>
|
Loading…
Reference in new issue