Skip to content

Commit 4105d05

Browse files
committed
DRY out
1 parent b1f761c commit 4105d05

File tree

4 files changed

+11
-23
lines changed

4 files changed

+11
-23
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export function VariableDeclaration(node, context) {
138138
if (rune === '$state' && is_proxy) {
139139
value = b.call('$.proxy', value);
140140

141-
if (dev) {
141+
if (dev && !is_state) {
142142
value = b.call('$.tag_proxy', value, b.literal(id.name));
143143
}
144144
}

packages/svelte/src/internal/client/dev/tracing.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ export function get_stack(label) {
187187
*/
188188
export function tag(source, label) {
189189
source.label = label;
190+
tag_proxy(source.v, label);
191+
190192
return source;
191193
}
192194

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

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { state as source, set } from './reactivity/sources.js';
1212
import { PROXY_PATH_SYMBOL, STATE_SYMBOL } from '#client/constants';
1313
import { UNINITIALIZED } from '../../constants.js';
1414
import * as e from './errors.js';
15-
import { get_stack, tag, tag_proxy } from './dev/tracing.js';
15+
import { get_stack, tag } from './dev/tracing.js';
1616
import { tracing_mode_flag } from '../flags/index.js';
1717

1818
// TODO move all regexes into shared module?
@@ -75,10 +75,7 @@ export function proxy(value) {
7575

7676
// rename all child sources and child proxies
7777
for (const [prop, source] of sources) {
78-
var label = get_label(path, prop);
79-
80-
tag(source, label);
81-
tag_proxy(source.v, label);
78+
tag(source, get_label(path, prop));
8279
}
8380
}
8481

@@ -165,9 +162,7 @@ export function proxy(value) {
165162
var s = source(p, stack);
166163

167164
if (DEV) {
168-
var label = get_label(path, prop);
169-
tag(s, label);
170-
tag_proxy(p, label);
165+
tag(s, get_label(path, prop));
171166
}
172167

173168
return s;
@@ -225,9 +220,7 @@ export function proxy(value) {
225220
var s = source(p, stack);
226221

227222
if (DEV) {
228-
var label = get_label(path, prop);
229-
tag(s, label);
230-
tag_proxy(p, label);
223+
tag(s, get_label(path, prop));
231224
}
232225

233226
return s;
@@ -281,23 +274,16 @@ export function proxy(value) {
281274
return s;
282275
});
283276

277+
sources.set(prop, s);
278+
284279
if (DEV) {
285-
var label = get_label(path, prop);
286-
tag(s, label);
287-
tag_proxy(s.v, label);
280+
tag(s, get_label(path, prop));
288281
}
289-
290-
sources.set(prop, s);
291282
}
292283
} else {
293284
has = s.v !== UNINITIALIZED;
294285

295286
var p = with_parent(() => proxy(value));
296-
297-
if (DEV) {
298-
tag_proxy(p, get_label(path, prop));
299-
}
300-
301287
set(s, p);
302288
}
303289

packages/svelte/src/internal/client/reactivity/sources.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export function set(source, value, should_proxy = false) {
141141

142142
let new_value = should_proxy ? proxy(value) : value;
143143

144-
if (DEV && should_proxy) {
144+
if (DEV) {
145145
tag_proxy(new_value, /** @type {string} */ (source.label));
146146
}
147147

0 commit comments

Comments
 (0)