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

Case when v-if v-else throws error and breaks app #4393

Closed
kamax1 opened this issue Dec 6, 2016 · 1 comment
Closed

Case when v-if v-else throws error and breaks app #4393

kamax1 opened this issue Dec 6, 2016 · 1 comment
Labels

Comments

@kamax1
Copy link

kamax1 commented Dec 6, 2016

Here is an example https://jsfiddle.net/h6azrhhz/

Template:

  <section>
    <template v-if="false">
    </template>
    <template v-else>
      <div v-if="condition" class="my-class">I'm loading</div>
      <div v-else>I'm loaded</div>
    </template>
  </section>

If v-if v-else block nested into another v-if, it produces error

VM205 vue.js:427TypeError: Cannot read property 'attrs' of undefined

when switching value of condition.

As i researched, need 3 conditions to reproduce the issue

  1. Class attr (or another attribute) must be presented presented in nested element
  2. Nested v-else must be presented
  3. v-if v-else must be nested into another v-if v-else

Workaround is to use v-if="condition" and v-if="!condition" instead of v-else

Thanks

@arnabrahman
Copy link

after the latest update 2.1.4 still facing the problem. For now using the workaround that @kamax1 described.

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

No branches or pull requests

3 participants