Browse Source

fix(compiler-core): fix v-on with modifiers on inline expression of undefined (#9866)

close #9865
improve isMemberExpression check for undefined
pull/9857/head
白雾三语 2 years ago
committed by GitHub
parent
commit
bae79ddf85
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      packages/compiler-core/__tests__/utils.spec.ts
  2. 2
      packages/compiler-core/src/utils.ts

4
packages/compiler-core/__tests__/utils.spec.ts

@ -122,6 +122,10 @@ describe('isMemberExpression', () => {
expect(fn(`123[a]`)).toBe(true)
expect(fn(`foo() as string`)).toBe(false)
expect(fn(`a + b as string`)).toBe(false)
// #9865
expect(fn('""')).toBe(false)
expect(fn('undefined')).toBe(false)
expect(fn('null')).toBe(false)
})
})

2
packages/compiler-core/src/utils.ts

@ -163,7 +163,7 @@ export const isMemberExpressionNode = __BROWSER__
return (
ret.type === 'MemberExpression' ||
ret.type === 'OptionalMemberExpression' ||
ret.type === 'Identifier'
(ret.type === 'Identifier' && ret.name !== 'undefined')
)
} catch (e) {
return false

Loading…
Cancel
Save