aaa
Rich Harris 8 months ago
parent 7c34419c6d
commit 69b95e6285

@ -12,6 +12,7 @@ export function AwaitExpression(node, context) {
let preserve_context = tla;
if (context.state.expression) {
context.state.expression.is_async = true;
suspend = true;
// wrap the expression in `(await $.save(...)).restore()` if necessary,
@ -20,14 +21,10 @@ export function AwaitExpression(node, context) {
while (i--) {
const parent = context.path[i];
if (
// stop walking up when we find a node with metadata, because that
// means we've hit the template node containing the expression
// @ts-expect-error we could probably use a neater/more robust mechanism
parent.metadata?.expression === context.state.expression ||
// @ts-expect-error
parent.metadata?.arguments?.includes(context.state.expression)
) {
break;
}
if (parent.metadata) break;
// TODO make this more accurate — we don't need to call suspend
// if this is the last thing that could be read
@ -43,9 +40,5 @@ export function AwaitExpression(node, context) {
context.state.analysis.suspenders.set(node, preserve_context);
}
if (context.state.expression) {
context.state.expression.is_async = true;
}
context.next();
}

Loading…
Cancel
Save