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

feat(v-model): add lazy modifier for v-model on components(close #6914) #6940

Closed
wants to merge 2 commits into from
Closed

feat(v-model): add lazy modifier for v-model on components(close #6914) #6940

wants to merge 2 commits into from

Conversation

javoski
Copy link
Member

@javoski javoski commented Oct 27, 2017

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

Other information:
close #6914 .

@javoski javoski changed the title feat(v-model): add lazy modifier on v-model for components(close #6914) feat(v-model): add lazy modifier for v-model on components(close #6914) Oct 27, 2017
@rstoenescu
Copy link
Contributor

Any news on this? Is it going to get merged, and if so, when is it scheduled to get into an official release? Thanks.

@posva
Copy link
Member

posva commented Dec 7, 2017

@javoski I think adding this feature should allow both using v-model and v-model.lazy, and therefore, a component could potentially have 2 different events for model


removed bad snippet of code, @javoski template solution is better

or with a render function as well http://jsfiddle.net/dazvtwat/

I do agree to have .lazy makes it more succinct though 🙂

@javoski
Copy link
Member Author

javoski commented Dec 8, 2017

@posva Yeah, it's reasonable for components to aware of if they are using .lazy modifier on v-model, and prop is a proper way.
But in the case of single input element wrapper component, I prefer to do like this:

const MyComp = {
  ...
  template: `<input :value="value" @input="onUpdate" @change="onUpdate">`,
  methods: {
    onUpdate (e) {
      this.$emit(e.type, e.target.value)
    }
  }
}

@posva
Copy link
Member

posva commented Dec 8, 2017

That's much better, indeed, completely forgot about event.type 😄
But we should allow the user to customize both, input and change events name emitted by the component because the component can be used in both scenarios but only one event name can be provided, and if it is provided, it will end up used by both v-model.lazy and v-model

@tmorehouse
Copy link

It would be nice for a component to actually know if the v-model is requesting a lazy (in some cases this may be required).

Native inputs will have element._vModifiers set with an object defining what modifiers are in use (i.e. { lazy: true, trim: true }, while the root element of a component will have this.$el.vModifiers set to an empty object, regardless of modifiers in use. It would be very handy to have these values made available to components (or maybe exposed as a readonly this.$vModifiers injection, although the former would be easier to implement)

Copy link

@PhilipJohnBasile PhilipJohnBasile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. 👍

@Tantawi
Copy link

Tantawi commented Mar 31, 2020

@javoski Can you please look at the merge conflicts and try to get this merged? thanks a lot!

@asennoussi
Copy link

@PhilipJohnBasile Please mege? :3

@Tantawi
Copy link

Tantawi commented Apr 24, 2020

@javoski Awesome now that it is approved, can you please look at the conflicts and merge? thanks a lot!

@PhilipJohnBasile
Copy link

There's merge conflics @Tantawi

@cn-xufei
Copy link

cn-xufei commented Dec 9, 2020

Exciting. When can we merge?

@javoski
Copy link
Member Author

javoski commented Dec 17, 2020

This PR was too old, so I opened a new one based on the latest codebase. #11830.

@javoski javoski closed this Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request: add v-model.lazy for components
9 participants