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

Disabling warnings about inline value attributes for v-model #3596

Closed
nfplee opened this issue Apr 13, 2021 · 12 comments
Closed

Disabling warnings about inline value attributes for v-model #3596

nfplee opened this issue Apr 13, 2021 · 12 comments
Labels
need guidance The approach/solution in the PR is unclear and requires guidance from maintainer to proceed further. ✨ feature request New feature or request

Comments

@nfplee
Copy link

nfplee commented Apr 13, 2021

Version

3.0.11

Steps to reproduce

Open the following:

https://jsfiddle.net/zqystjur/

The following warning will be thrown:

[Vue warn]: Template compilation error: Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.


This seems to relate to the following Vue 2 issue:

vuejs/vue#4733

@nfplee
Copy link
Author

nfplee commented Apr 13, 2021

What about when using :value alongside the value attribute? From my understanding v-model is shorthand for :value="foo" @input="foo = $event.target.value". However when using :value it doesn't seem to override the value attribute unlike v-model. See the following for an example:

https://jsfiddle.net/s2orke8c/

No warning is thrown but maybe one should be thrown in this case, unless this is a bug.

@posva
Copy link
Member

posva commented Apr 13, 2021

@phanan I think your input would be valuable here

@phanan
Copy link
Member

phanan commented Apr 13, 2021

Hmm, TBH I'm not sure why this 1.x behavior was revived in v3, but I still tend to agree with 4-year-ago me 😄 that this warning isn't extremely helpful. Again, as the original v2 issue author said, there are frameworks/libraries/CMSes that generate inline value attributes, which would cause this warning to be thrown all over the place. I'd vote for removal.

@posva
Copy link
Member

posva commented Apr 13, 2021

what about :value and this proposal

@phanan
Copy link
Member

phanan commented Apr 14, 2021

AFAIU there's no warning for :value, which is expected right? But I'd tend to agree that :value not overriding value sounds weird. Maybe @yyx990803 can shed a light on both topics here?

@posva
Copy link
Member

posva commented Apr 14, 2021

Now that I read the comment again, I was more thinking of a :value with a v-model throwing a warning instead of any value attribute with a v-model

@phanan
Copy link
Member

phanan commented Apr 14, 2021

That makes perfect sense @posva. The two bindings with conflicting effects should have a warning. Binding vs static shouldn't.

@nfplee
Copy link
Author

nfplee commented Apr 14, 2021

I personally feel that :value should override the value attribute (to be consistent with v-model). But I agree it makes sense to throw a warning if :value is used with v-model.

@HcySunYang HcySunYang added the need guidance The approach/solution in the PR is unclear and requires guidance from maintainer to proceed further. label Apr 15, 2021
@nfplee
Copy link
Author

nfplee commented May 10, 2021

It seems the order of the attributes is important. See the following:

https://jsfiddle.net/xm270v6y/

Therefore my new conclusion is that it should throw a warning if :value is used with v-model or :value is used after a value attribute (but not before).

There is a similar issue when using v-text and v-html attribute's on elements which contains server-side rendered content. See the following example:

https://jsfiddle.net/jbfqsgd1/

Once again I feel these warnings are counter intuitive and actually discourage one of the great features of Vue in that you can render an initial value (which matches the data-bound value) and have Vue later override it. One use case for this is for multi-page applications where I have replaced some of the jQuery plugins with Vue components. If the server-side rendered code doesn't match the output after the Vue instance is mounted then there will be a flicker as the content changes.

@nfplee
Copy link
Author

nfplee commented Jul 6, 2021

I've been looking at petite-vue this weekend and that's exactly how I've been using Vue. This is why I believe these warnings should be removed since they interfere with SSR and Vue should ideally be a superset of Petite-Vue.

@nfplee
Copy link
Author

nfplee commented Jan 6, 2022

Any update on this? Another idea would be to add a config option to ignore particular warnings.

@u01jmg3
Copy link

u01jmg3 commented Oct 23, 2023

Any update on this for 2023? It would be great to be able to control this warning.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need guidance The approach/solution in the PR is unclear and requires guidance from maintainer to proceed further. ✨ feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants