Skip to content
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

fix(v-model): create non-existent properties as reactive #80

Merged
merged 1 commit into from Oct 5, 2019

Conversation

@allex
Copy link
Contributor

commented Sep 19, 2019

fix v-model assign non-existent properties as reactive.

<MyComponent vModel={a.b} />

to

<MyComponent model={{
  value: a.b,
  callback: $$v => {
    this.$set(a, "b", $$v); // a.b = $$v;
  }
}} />
@sodatea
sodatea approved these changes Oct 5, 2019
@sodatea sodatea merged commit a075fd3 into vuejs:dev Oct 5, 2019
@vue-bot

This comment has been minimized.

Copy link

commented Oct 5, 2019

Hey @allex, thank you for your time and effort spent on this PR, contributions like yours help make Vue better for everyone. Cheers! 💚

@jvbianchi

This comment has been minimized.

Copy link

commented Oct 13, 2019

If you use JSX inside setup, this won't be defined (as per spec) and this PR will cause errors.

@sodatea

This comment has been minimized.

Copy link
Member

commented Oct 13, 2019

@jvbianchi Any reproductions? Also, I think @vue/composition-api is not fully compatible with this preset anyway. Before this PR, we already transformed code like vModel={a['b']}.

@jvbianchi

This comment has been minimized.

Copy link

commented Oct 13, 2019

@sodatea here is the reproduction: https://github.com/jvbianchi/jsx-vmodel-reproduction

just change the value in the input, you will get this error:

[Vue warn]: Error in v-on handler: "TypeError: Cannot read property '$set' of undefined"

TypeError: Cannot read property '$set' of undefined

Before this PR it worked fine.

@tiepnguyen

This comment has been minimized.

Copy link

commented Oct 15, 2019

@jvbianchi this issue is real, I also ran into this error 2 days ago after npm update and I didn't know why until I found this PR, now all my v-model inside setup() are not working. May becus this does not exist in setup() ? I don't know but trying to roll back to 1.1.0

@jvbianchi

This comment has been minimized.

Copy link

commented Oct 15, 2019

@tiepnguyen Yes, if you rollback to a previous version, it works fine.

@sodatea Should I open a new issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.