mirror of https://github.com/vuejs/core.git
fix(transform): validate property name for v-bind shorthand
This commit is contained in:
parent
fd7d6cf67e
commit
503b4b5ce6
|
@ -6,6 +6,7 @@ import {
|
|||
} from '../ast'
|
||||
import type { NodeTransform } from '../transform'
|
||||
import { ErrorCodes, createCompilerError } from '../errors'
|
||||
import { validFirstIdentCharRE } from '../utils'
|
||||
|
||||
export const transformVBindShorthand: NodeTransform = (node, context) => {
|
||||
if (node.type === NodeTypes.ELEMENT) {
|
||||
|
@ -28,7 +29,9 @@ export const transformVBindShorthand: NodeTransform = (node, context) => {
|
|||
prop.exp = createSimpleExpression('', true, arg.loc)
|
||||
} else {
|
||||
const propName = camelize((arg as SimpleExpressionNode).content)
|
||||
prop.exp = createSimpleExpression(propName, false, arg.loc)
|
||||
if (validFirstIdentCharRE.test(propName[0])) {
|
||||
prop.exp = createSimpleExpression(propName, false, arg.loc)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ enum MemberExpLexState {
|
|||
inString,
|
||||
}
|
||||
|
||||
const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/
|
||||
export const validFirstIdentCharRE: RegExp = /[A-Za-z_$\xA0-\uFFFF]/
|
||||
const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/
|
||||
const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g
|
||||
|
||||
|
|
Loading…
Reference in New Issue