vuejs / vue

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
http://v2.vuejs.org
MIT License
207.97k stars 33.68k forks source link

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

Open simonhermann opened 5 years ago

simonhermann commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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"
/>
chrisdel101 commented 5 years ago

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

posva commented 5 years ago

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

zvf618 commented 5 years ago

习惯就好

WhiteDevill11 commented 5 years ago

@simonhermann

oielbanna commented 3 years ago

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

amandesai01 commented 2 years ago

Why is this issue still open?

EdisonChenNanjing commented 2 years ago

Niu Bi

manishSharma1-dev commented 6 months ago

Why is this issue still open ?

simonhermann commented 6 months ago

Just to make it clear: I opened this issue, but that does not mean I have the right to merge PRs. We need to maintainers to merge the PR, then the issue can be closed.

amandesai01 commented 6 months ago

@simonhermann when we say why issue is open, it's a question to maintainers obviously.