mirror of https://github.com/vuejs/core.git
fix(compiler-core): fix bail constant for globals
This commit is contained in:
parent
638a79f64a
commit
fefce06b41
|
@ -431,6 +431,21 @@ describe('compiler: expression transform', () => {
|
|||
})
|
||||
})
|
||||
|
||||
test('should not bail constant on strings w/ ()', () => {
|
||||
const node = parseWithExpressionTransform(
|
||||
`{{ new Date().getFullYear() }}`,
|
||||
) as InterpolationNode
|
||||
expect(node.content).toMatchObject({
|
||||
children: [
|
||||
'new ',
|
||||
{ constType: ConstantTypes.NOT_CONSTANT },
|
||||
'().',
|
||||
{ constType: ConstantTypes.NOT_CONSTANT },
|
||||
'()',
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
describe('ES Proposals support', () => {
|
||||
test('bigInt', () => {
|
||||
const node = parseWithExpressionTransform(
|
||||
|
|
|
@ -311,7 +311,12 @@ export function processExpression(
|
|||
} else {
|
||||
// The identifier is considered constant unless it's pointing to a
|
||||
// local scope variable (a v-for alias, or a v-slot prop)
|
||||
if (!(needPrefix && isLocal)) {
|
||||
if (
|
||||
!(needPrefix && isLocal) &&
|
||||
parent.type !== 'CallExpression' &&
|
||||
parent.type !== 'NewExpression' &&
|
||||
parent.type !== 'MemberExpression'
|
||||
) {
|
||||
;(node as QualifiedId).isConstant = true
|
||||
}
|
||||
// also generate sub-expressions for other identifiers for better
|
||||
|
|
Loading…
Reference in New Issue