Skip to content

Commit 873cd5f

Browse files
committed
fix: double log on push
1 parent 55fdccc commit 873cd5f

File tree

1 file changed

+9
-5
lines changed
  • packages/svelte/src/internal/client

1 file changed

+9
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ function clone_options(options) {
3333
/**
3434
* @template T
3535
* @param {T} value
36-
* @param {ValueOptions} [options]
36+
* @param {ValueOptions} [_options]
3737
* @param {ProxyMetadata | null} [parent]
3838
* @param {Source<T>} [prev] dev mode only
3939
* @returns {T}
4040
*/
41-
export function proxy(value, options, parent = null, prev) {
41+
export function proxy(value, _options, parent = null, prev) {
42+
let options = clone_options(_options);
4243
/** @type {Error | null} */
4344
var stack = null;
4445
if (DEV && tracing_mode_flag) {
@@ -80,7 +81,10 @@ export function proxy(value, options, parent = null, prev) {
8081
if (is_proxied_array) {
8182
// We need to create the length source eagerly to ensure that
8283
// mutations to the array are properly synced with our proxy
83-
sources.set('length', source(/** @type {any[]} */ (value).length, options, stack));
84+
sources.set(
85+
'length',
86+
source(/** @type {any[]} */ (value).length, clone_options(options), stack)
87+
);
8488
}
8589

8690
/** @type {ProxyMetadata} */
@@ -183,9 +187,9 @@ export function proxy(value, options, parent = null, prev) {
183187
// to the onchanges array or we set every source onchange
184188
// to the passed in value (if it's undefined it will make the chain stop)
185189
if (options?.onchange != null && value && !remove) {
186-
onchanges.add(value);
190+
onchanges?.add?.(value);
187191
} else if (options?.onchange != null && value) {
188-
onchanges.delete(value);
192+
onchanges?.delete?.(value);
189193
} else {
190194
options = {
191195
onchange: value

0 commit comments

Comments
 (0)