Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(compiler-core,v-model): create transform for v-model#146

Merged
yyx990803 merged 9 commits into
vuejs:masterfrom
znck:feat/v-model
Oct 10, 2019
Merged

feat(compiler-core,v-model): create transform for v-model#146
yyx990803 merged 9 commits into
vuejs:masterfrom
znck:feat/v-model

Conversation

@znck

@znck znck commented Oct 7, 2019

Copy link
Copy Markdown
Member

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
Comment thread packages/compiler-core/src/transforms/vModel.ts Outdated
Comment thread packages/compiler-core/src/transforms/vModel.ts Outdated
Comment thread packages/compiler-core/__tests__/transforms/vModel.spec.ts
@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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