fix(compiler-core): improve the isMemberExpression function (#3675)
This commit is contained in:
@@ -56,10 +56,14 @@ const nonIdentifierRE = /^\d|[^\$\w]/
|
||||
export const isSimpleIdentifier = (name: string): boolean =>
|
||||
!nonIdentifierRE.test(name)
|
||||
|
||||
const memberExpRE = /^[A-Za-z_$\xA0-\uFFFF][\w$\xA0-\uFFFF]*(?:\s*\.\s*[A-Za-z_$\xA0-\uFFFF][\w$\xA0-\uFFFF]*|\[[^\]]+\])*$/
|
||||
const memberExpRE = /^[A-Za-z_$\xA0-\uFFFF][\w$\xA0-\uFFFF]*(?:\s*\.\s*[A-Za-z_$\xA0-\uFFFF][\w$\xA0-\uFFFF]*|\[(.+)\])*$/
|
||||
export const isMemberExpression = (path: string): boolean => {
|
||||
if (!path) return false
|
||||
return memberExpRE.test(path.trim())
|
||||
const matched = memberExpRE.exec(path.trim())
|
||||
if (!matched) return false
|
||||
if (!matched[1]) return true
|
||||
if (!/[\[\]]/.test(matched[1])) return true
|
||||
return isMemberExpression(matched[1].trim())
|
||||
}
|
||||
|
||||
export function getInnerRange(
|
||||
|
||||
Reference in New Issue
Block a user