Subscribe on changes!

v-if is executed even when v-for doesnt iterate anything

avatar
Aug 31st 2020

Version

3.0.0-rc.9

Reproduction link

https://codesandbox.io/s/amazing-feistel-udure?file=/src/App.vue

Steps to reproduce

Open the link and open the console.

Alternatively put an v-if on an element with v-for which iterates through an empty array and throw an error in the v-if computed property or call debugger.

What is expected?

The error should not be thrown (or the debugger statement not beeing executed)

What is actually happening?

The error is thrown


It seems that v-if is evaluated even though v-for was passed an empty array and hence has nothing to iterate over.

The docs say, that v-for is evaluated first and that's how it was in vue 2 but somehow this behavior changed.

PS: I am aware, that for that exact reason you shouldn't use both on an element. However, it should still work!

avatar
Aug 31st 2020

Related: #1165.