-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fixed v-for/v-if priority and explanations #540
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!👍
Thanks quick fixes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NataliaTepluhina Thanks for inviting me to participate in the review for this.
I have made some suggestions, I hope they're helpful.
src/guide/list.md
Outdated
|
||
```html | ||
<li v-for="todo in todos" v-if="!todo.isComplete"> | ||
<!-- Property "todo" was accessed during render but is not defined on instance. --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs moving up a line. It's potentially confusing because the next line also mentions todo
. Perhaps that line should be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should remove this line altogether because we need to show that this code snippet is incorrect. I changed a message to reflect this better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, I wasn't clear.
I wasn't suggesting removing the comment line. I was suggesting removing the next line, {{ todo }}
. The problem is that it mentions todo
, so it wasn't entirely clear whether the error message was referring to the v-if
or the {{ todo }}
.
Moving the comment up has helped. I just wonder whether replacing the {{ todo }}
with, e.g. ...
or a comment would remove any potential for someone to misunderstand? One of the earlier examples uses <!-- content -->
, so perhaps that?
<li v-for="todo in todos" v-if="!todo.isComplete">
<!-- content -->
</li>
Now I look a bit closer there's actually another problem with the {{ todo }}
. The v-if="todo.isComplete"
implies that todo
is an object with an isComplete
property but the {{ todo }}
seems to be treating todo
like it's a string. It isn't technically wrong, I just worry about someone getting distracted by the {{ todo }}
and thinking it has something to do with the error.
If you do decide to change it then the next example would need updating to match.
@skirtles-code thank you for the awesomely thorough review and suggestions! I've applied fixes, would you mind taking a second look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍 I'm being an annoying nitpicker again and left some non-blocking comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NataliaTepluhina I've made one more comment trying to clarify my earlier suggestion about one of the examples. I might just be worrying about nothing.
Happy for this to be merged if you don't think it's worth changing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on this @NataliaTepluhina! Other than the phrasing suggestions An added in the PR, it looks good to me!
Co-authored-by: Phan An <me@phanan.net>
Co-authored-by: Phan An <me@phanan.net>
* fix: fixed v-if v-for on styleguide * fix: fixed directives API for v-if v-for * fix: fixed v-if with v-for on list * fix: fixed conditional for v-if * fix: fixed typo * fix: fixed directives.md * fix: fixed error on list * fix: fixed grammar * fix: fixed styleguide `li` mention * fix: fixed grammar * Update src/api/directives.md Co-authored-by: Phan An <me@phanan.net> * Update src/guide/conditional.md Co-authored-by: Phan An <me@phanan.net> Co-authored-by: Phan An <me@phanan.net>
Description of Problem
In v3, the precedence of v-for and v-if when used on the same node is is now switched.
Proposed Solution
Update respective sections of the guide
Additional Information
Close #534