Skip to content

Commit 5393361

Browse files
Apply suggestions from code review
Co-authored-by: Rich Harris <[email protected]>
1 parent 23a4e7c commit 5393361

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

.changeset/hot-buses-end.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'svelte': patch
33
---
44

5-
feat: add parent hierarchy to \_\_svelte_meta objects at dev time
5+
feat: add parent hierarchy to `__svelte_meta` objects

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,14 +416,12 @@ export function with_dev_stack(call_expression, node, type, additional) {
416416
return b.stmt(
417417
b.call(
418418
'$.with_dev_stack',
419-
b.arrow([], b.block([b.stmt(call_expression)])),
419+
b.arrow([], call_expression),
420420
b.literal(type),
421421
b.literal(filename),
422422
b.literal(location.line),
423423
b.literal(location.column),
424-
additional
425-
? b.object(Object.entries(additional).map(([key, value]) => b.init(key, b.literal(value))))
426-
: b.null
424+
additional && b.object(Object.entries(additional).map(([k, v]) => b.init(k, b.literal(v))))
427425
)
428426
);
429427
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,21 @@ export function set_dev_stack(stack) {
3939
* @returns {any}
4040
*/
4141
export function with_dev_stack(callback, type, file, line, column, additional) {
42-
/** @type {DevStackEntry} */
43-
const new_entry = {
42+
const parent = dev_stack;
43+
44+
dev_stack = {
4445
type,
4546
file,
4647
line,
4748
column,
48-
parent: dev_stack,
49+
parent,
4950
...additional
5051
};
51-
const previous_stack = dev_stack;
52-
dev_stack = new_entry;
5352

5453
try {
5554
return callback();
5655
} finally {
57-
dev_stack = previous_stack;
56+
dev_stack = parent;
5857
}
5958
}
6059

0 commit comments

Comments
 (0)