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

Warn if colon shorthand is used on v-if/v-html/etc. #10191

Open
simonhermann opened this issue Jun 25, 2019 · 10 comments · May be fixed by #10199
Open

Warn if colon shorthand is used on v-if/v-html/etc. #10191

simonhermann opened this issue Jun 25, 2019 · 10 comments · May be fixed by #10199

Comments

@simonhermann
Copy link

What problem does this feature solve?

I just spent way too long debugging something really weird until I realized I accidentally wrote :v-if instead of v-if.

A warning when wrongly using shorthands like : on "native" vue attributes could prevent this bad experience easily.

What does the proposed API look like?

:v-if="foo"

--> console.warn("You specified v-bind:/ v-on: or a corresponding shorthand on a Vue attribute like v-if or similar. Usually this does not make sense.)

@posva
Copy link
Member

posva commented Jun 25, 2019

I've seen this happen so often when teaching Vue that even though having a prop named vIf is technically valid, I think this warning would help much more people than ever hurt

@simonhermann
Copy link
Author

simonhermann commented Jun 25, 2019

Yes. If you wanted a prop, why should have the same name as a v-attribute. That'd be incredibly confusing.

<ConfusingComponent 
  v-if="true"
  :v-if="false"
/>

afontcu added a commit to afontcu/vue that referenced this issue Jun 25, 2019
@posva posva added the has PR label Jun 26, 2019
@chrisdel101
Copy link

I'll take this on. It'll be my first issue here.

@posva
Copy link
Member

posva commented Jun 30, 2019

Thanks but as the tag suggest there is already a Pull request for this

@zvf618
Copy link

zvf618 commented Sep 3, 2019

习惯就好

@WhiteDevill11
Copy link

@simonhermann

@oielbanna
Copy link

oielbanna commented Dec 18, 2020

I was going to give it a go but it seems there's a super old PR for this already

@amandesai01
Copy link

Why is this issue still open?

@EdisonChenNanjing
Copy link

Niu Bi

@manish-sharma-dev
Copy link

Why is this issue still open ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants