Skip to content

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

Merged
merged 9 commits into from
Oct 10, 2019

Conversation

znck
Copy link
Member

@znck znck commented Oct 7, 2019

This PR is based on v-model RFC. The runtime handling of onUpdate: prefixed events would be implemented in a separate PR to runtime-dom.

@znck znck changed the title [WIP] feat(compiler): create transform for v-model feat(compiler-core,v-model): create transform for v-model Oct 8, 2019
@znck znck marked this pull request as ready for review October 8, 2019 18:34
@znck znck requested a review from yyx990803 October 8, 2019 18:57
@znck znck requested a review from yyx990803 October 10, 2019 02:45
Comment on lines +34 to +63
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)'
]
}
})
Copy link
Member

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)
Copy link
Member

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?

Copy link
Member

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.

@yyx990803 yyx990803 merged commit 87c3d2e into vuejs:master Oct 10, 2019
@znck znck deleted the feat/v-model branch October 10, 2019 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants