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 '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( return b.stmt(
b.call( b.call(
'$.with_dev_stack', '$.with_dev_stack',
b.arrow([], b.block([b.stmt(call_expression)])), b.arrow([], call_expression),
b.literal(type), b.literal(type),
b.literal(filename), b.literal(filename),
b.literal(location.line), b.literal(location.line),
b.literal(location.column), b.literal(location.column),
additional additional && b.object(Object.entries(additional).map(([k, v]) => b.init(k, b.literal(v))))
? b.object(Object.entries(additional).map(([key, value]) => b.init(key, b.literal(value))))
: b.null
) )
); );
} }

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

Loading…
Cancel
Save