Skip to content

Commit 69b95e6

Browse files
committed
tidy up
1 parent 7c34419 commit 69b95e6

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitExpression.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export function AwaitExpression(node, context) {
1212
let preserve_context = tla;
1313

1414
if (context.state.expression) {
15+
context.state.expression.is_async = true;
1516
suspend = true;
1617

1718
// wrap the expression in `(await $.save(...)).restore()` if necessary,
@@ -20,14 +21,10 @@ export function AwaitExpression(node, context) {
2021
while (i--) {
2122
const parent = context.path[i];
2223

23-
if (
24-
// @ts-expect-error we could probably use a neater/more robust mechanism
25-
parent.metadata?.expression === context.state.expression ||
26-
// @ts-expect-error
27-
parent.metadata?.arguments?.includes(context.state.expression)
28-
) {
29-
break;
30-
}
24+
// stop walking up when we find a node with metadata, because that
25+
// means we've hit the template node containing the expression
26+
// @ts-expect-error we could probably use a neater/more robust mechanism
27+
if (parent.metadata) break;
3128

3229
// TODO make this more accurate — we don't need to call suspend
3330
// if this is the last thing that could be read
@@ -43,9 +40,5 @@ export function AwaitExpression(node, context) {
4340
context.state.analysis.suspenders.set(node, preserve_context);
4441
}
4542

46-
if (context.state.expression) {
47-
context.state.expression.is_async = true;
48-
}
49-
5043
context.next();
5144
}

0 commit comments

Comments
 (0)