no need to create a source outside an effect here, because it can't result in a reference

pull/11109/head
Rich Harris 2 years ago
parent 6cb0605c7f
commit f110bda147

@ -1,5 +1,11 @@
import { DEV } from 'esm-env';
import { get, batch_inspect, current_component_context, untrack } from './runtime.js';
import {
get,
batch_inspect,
current_component_context,
untrack,
current_effect
} from './runtime.js';
import {
array_prototype,
define_property,
@ -243,7 +249,10 @@ const state_proxy_handler = {
const has = Reflect.has(target, prop);
let s = metadata.s.get(prop);
if (s !== undefined || !has || get_descriptor(target, prop)?.writable) {
if (
s !== undefined ||
(current_effect !== null && (!has || get_descriptor(target, prop)?.writable))
) {
if (s === undefined) {
s = (metadata.i ? source : mutable_source)(
has ? proxy(target[prop], metadata.i, metadata.o) : UNINITIALIZED

Loading…
Cancel
Save