Skip to content

Strange error, when we watch and work with the list. #728

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

Closed
grimalschi opened this issue Feb 27, 2015 · 3 comments
Closed

Strange error, when we watch and work with the list. #728

grimalschi opened this issue Feb 27, 2015 · 3 comments
Labels

Comments

@grimalschi
Copy link

Demo: http://jsfiddle.net/e9e2bw6v/2/

We have list, which is under watching. In watch we just replace text:null to text: 'some text'.

When we add an item, and later we clear list, we see error.

We have html:
<div v-if="list.length">
<div v-if="list[0].text">
{{list[0].text}}
</div>
</div>

If we remove second condition, we will not have error.

If you replace 2 conditions to 1 <div v-if="list.length && list[0].text">, we will not have error.

I cannot explain this, but its wrong.

P.S. Sory for bad english.

@grimalschi
Copy link
Author

I found another way to get this error - after add item we run timeout, and in timeout we set value.

After cleaning list we will see error.

Demo: http://jsfiddle.net/4peaumas/1/

@grimalschi
Copy link
Author

Note: if we change default value from "text: null" to "text: 'default'", it will be work well.

@multimeric
Copy link

I guess to summarize the problem for anyone else, when the list is cleared, both of the v-if conditions are now false (list.length and list[0].text). However the inner condition (list[0].text) is still executed, resulting in an error, even though it should have been skipped due to the outer condition evaluating to false.

So it looks like v-ifs should be evaluated hierachically instead of in the order they are evaluated now.

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