fix(reactivity-transform): fix props access codegen for non-identifier prop names (#5436)

fix #5425
This commit is contained in:
edison
2022-05-13 10:38:46 +08:00
committed by GitHub
parent 0c07f12541
commit 242914d938
6 changed files with 69 additions and 10 deletions

View File

@@ -171,3 +171,11 @@ export const getGlobalThis = (): any => {
: {})
)
}
const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/
export function genPropsAccessExp(name: string) {
return identRE.test(name)
? `__props.${name}`
: `__props[${JSON.stringify(name)}]`
}