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

close #9865
improve isMemberExpression check for undefined
This commit is contained in:
白雾三语 2023-12-19 17:08:46 +08:00 committed by GitHub
parent 24b1c1dd57
commit bae79ddf85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -122,6 +122,10 @@ describe('isMemberExpression', () => {
expect(fn(`123[a]`)).toBe(true) expect(fn(`123[a]`)).toBe(true)
expect(fn(`foo() as string`)).toBe(false) expect(fn(`foo() as string`)).toBe(false)
expect(fn(`a + b 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)
}) })
}) })

View File

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