-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
feat(compiler-core,v-model): create transform for v-model #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
const props = ((node.codegenNode as CallExpression) | ||
.arguments[1] as ObjectExpression).properties | ||
|
||
expect(props[0]).toMatchObject({ | ||
key: { | ||
content: 'modelValue', | ||
isStatic: true | ||
}, | ||
value: { | ||
content: 'model', | ||
isStatic: false | ||
} | ||
}) | ||
|
||
expect(props[1]).toMatchObject({ | ||
key: { | ||
content: 'onUpdate:modelValue', | ||
isStatic: true | ||
}, | ||
value: { | ||
children: [ | ||
'$event => (', | ||
{ | ||
content: 'model', | ||
isStatic: false | ||
}, | ||
' = $event)' | ||
] | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be?
expect(node.codegenNode).toMatchObject({
arguments: [
{
properties: [
{
key: {
content: "modelValue",
isStatic: true
},
value: {
content: "model",
isStatic: false
}
},
{
key: {
content: "onUpdate:modelValue",
isStatic: true
},
value: {
children: [
"$event => (",
{
content: "model",
isStatic: false
},
" = $event)"
]
}
}
]
}
]
});
|
||
if (isEmptyExpression(exp)) { | ||
context.onError( | ||
createCompilerError(ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the error be empty
instead of generic malformed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, both cases can actually be using the same error. I'll adjust this after merge.
This PR is based on v-model RFC. The runtime handling of
onUpdate:
prefixed events would be implemented in a separate PR toruntime-dom
.