fix(v-model): generate separate modifiers for v-model with args
This commit is contained in:
@@ -43,13 +43,12 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
|
||||
const propName = arg ? arg : createSimpleExpression('modelValue', true)
|
||||
const eventName = arg
|
||||
? arg.type === NodeTypes.SIMPLE_EXPRESSION && arg.isStatic
|
||||
? createSimpleExpression('onUpdate:' + arg.content, true)
|
||||
? `onUpdate:${arg.content}`
|
||||
: createCompoundExpression([
|
||||
createSimpleExpression('onUpdate:', true),
|
||||
'+',
|
||||
'"onUpdate:" + ',
|
||||
...(arg.type === NodeTypes.SIMPLE_EXPRESSION ? [arg] : arg.children)
|
||||
])
|
||||
: createSimpleExpression('onUpdate:modelValue', true)
|
||||
: `onUpdate:modelValue`
|
||||
|
||||
const props = [
|
||||
// modelValue: foo
|
||||
@@ -80,9 +79,19 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
|
||||
const modifiers = dir.modifiers
|
||||
.map(m => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`)
|
||||
.join(`, `)
|
||||
const modifiersKey = arg
|
||||
? arg.type === NodeTypes.SIMPLE_EXPRESSION && arg.isStatic
|
||||
? `${arg.content}Modifiers`
|
||||
: createCompoundExpression([
|
||||
...(arg.type === NodeTypes.SIMPLE_EXPRESSION
|
||||
? [arg]
|
||||
: arg.children),
|
||||
' + "Modifiers"'
|
||||
])
|
||||
: `modelModifiers`
|
||||
props.push(
|
||||
createObjectProperty(
|
||||
`modelModifiers`,
|
||||
modifiersKey,
|
||||
createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, true)
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user