Skip to content

Commit 13fa2f4

Browse files
committed
fix(compiler): use parseExpression instead of walkIdentifiers
1 parent 4d17aa5 commit 13fa2f4

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

packages/compiler/src/utils.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
isLiteralWhitelisted,
1818
NodeTypes,
1919
unwrapTSNode,
20-
walkIdentifiers,
2120
type SimpleExpressionNode,
2221
type TextNode,
2322
} from '@vue/compiler-dom'
@@ -137,7 +136,7 @@ export function resolveExpression(
137136
if (!node) return createSimpleExpression('', true)
138137
node = unwrapTSNode(
139138
node.type === 'JSXExpressionContainer' ? node.expression : node,
140-
)
139+
) as Node
141140
const isStatic =
142141
node.type === 'StringLiteral' ||
143142
node.type === 'JSXText' ||
@@ -163,20 +162,17 @@ export function resolveExpression(
163162
node.start! -= 7
164163
}
165164
}
166-
if (!isResolved) {
167-
const offset = node.start! - 1
168-
walkIdentifiers(
169-
node,
170-
(id) => {
171-
if (!id.loc) return
172-
id.start = id.loc.start.index! - offset
173-
id.end = id.loc.end.index! - offset
174-
},
175-
true,
176-
)
177-
resolvedExpressions.add(node)
178-
}
179-
return resolveSimpleExpression(source, isStatic, location, node)
165+
166+
return resolveSimpleExpression(
167+
source,
168+
isStatic,
169+
location,
170+
isStatic
171+
? undefined
172+
: parseExpression(`(${source})`, {
173+
plugins: context.options.expressionPlugins,
174+
}),
175+
)
180176
}
181177

182178
export function resolveSimpleExpression(
@@ -309,7 +305,7 @@ export function resolveExpressionWithFn(node: Node, context: TransformContext) {
309305
false,
310306
node.loc,
311307
parseExpression(`(${text})=>{}`, {
312-
plugins: ['typescript'],
308+
plugins: context.options.expressionPlugins,
313309
}),
314310
)
315311
}

0 commit comments

Comments
 (0)