Apply suggestions from code review

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/16255/head
Simon H 3 months ago committed by GitHub
parent 23a4e7c163
commit 53933619e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -2,4 +2,4 @@
'svelte': patch
---
feat: add parent hierarchy to \_\_svelte_meta objects at dev time
feat: add parent hierarchy to `__svelte_meta` objects

@ -416,14 +416,12 @@ export function with_dev_stack(call_expression, node, type, additional) {
return b.stmt(
b.call(
'$.with_dev_stack',
b.arrow([], b.block([b.stmt(call_expression)])),
b.arrow([], call_expression),
b.literal(type),
b.literal(filename),
b.literal(location.line),
b.literal(location.column),
additional
? b.object(Object.entries(additional).map(([key, value]) => b.init(key, b.literal(value))))
: b.null
additional && b.object(Object.entries(additional).map(([k, v]) => b.init(k, b.literal(v))))
)
);
}

@ -39,22 +39,21 @@ export function set_dev_stack(stack) {
* @returns {any}
*/
export function with_dev_stack(callback, type, file, line, column, additional) {
/** @type {DevStackEntry} */
const new_entry = {
const parent = dev_stack;
dev_stack = {
type,
file,
line,
column,
parent: dev_stack,
parent,
...additional
};
const previous_stack = dev_stack;
dev_stack = new_entry;
try {
return callback();
} finally {
dev_stack = previous_stack;
dev_stack = parent;
}
}

Loading…
Cancel
Save