Skip to content

Commit 533bd9d

Browse files
authored
fix: better update proxy version (#10614)
1 parent 2de7412 commit 533bd9d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

packages/svelte/src/internal/client/proxy.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import { DEV } from 'esm-env';
22
import {
33
get,
44
set,
5-
update,
65
updating_derived,
76
batch_inspect,
87
current_component_context,
9-
set_ignore_mutation_validation,
10-
untrack
8+
untrack,
9+
set_signal_value
1110
} from './runtime.js';
1211
import { effect_active } from './reactivity/computations.js';
1312
import {
@@ -150,6 +149,15 @@ export function unstate(value) {
150149
);
151150
}
152151

152+
/**
153+
* @param {import('./types.js').Signal<number>} signal
154+
* @param {1 | -1} [d]
155+
*/
156+
function update_version(signal, d = 1) {
157+
const value = untrack(() => get(signal));
158+
set_signal_value(signal, value + d);
159+
}
160+
153161
/** @type {ProxyHandler<import('./types.js').ProxyStateObject<any>>} */
154162
const state_proxy_handler = {
155163
defineProperty(target, prop, descriptor) {
@@ -185,9 +193,7 @@ const state_proxy_handler = {
185193
if (s !== undefined) set(s, UNINITIALIZED);
186194

187195
if (boolean) {
188-
set_ignore_mutation_validation(true);
189-
update(metadata.v);
190-
set_ignore_mutation_validation(false);
196+
update_version(metadata.v);
191197
}
192198

193199
return boolean;
@@ -308,9 +314,7 @@ const state_proxy_handler = {
308314
set(ls, length);
309315
}
310316
}
311-
set_ignore_mutation_validation(true);
312-
update(metadata.v);
313-
set_ignore_mutation_validation(false);
317+
update_version(metadata.v);
314318
}
315319

316320
return true;

packages/svelte/src/internal/client/runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ export function inspect(get_value, inspect = console.log) {
13321332

13331333
pre_effect(() => {
13341334
const fn = () => {
1335-
const value = get_value().map((v) => deep_unstate(v));
1335+
const value = untrack(() => get_value().map((v) => deep_unstate(v)));
13361336
if (value.length === 2 && typeof value[1] === 'function' && !warned_inspect_changed) {
13371337
// eslint-disable-next-line no-console
13381338
console.warn(

0 commit comments

Comments
 (0)