-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
"Cannot read property '0' of null" thrown when appending to empty array in slot content #2912
Labels
Comments
haferje
changed the title
v-for as slot content with empty array throws exception "Cannot read property '0' of null"
"Cannot read property '0' of null" thrown when appending to empty array in slot content
Dec 29, 2020
Wasn't this already fixed but not released? |
Possible, could have missed that. |
Tested on master and works |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Version
3.0.4
Reproduction link
https://jsfiddle.net/haferje/fs458ycu/15/
Steps to reproduce
What is expected?
I assume the Box component slot would render as blank or the default slot content, if the v-for acts on an empty array, but display the array items when it is mutated.
What is actually happening?
Upon adding an item to the empty array, the Box component re-renders its slot, but is trying to access the 0 index in patchBlockChildren(), which it didn't previously render. This throws an exception, but I would expect it to render a single item where there would previously be no items.
I would expect a v-for iterated tag in a component slot to show no items when the item array is empty, or show the default slot content. When I push an item on the array, I would expect the item to be shown in the slot and replace any default slot content. However, when the first item is pushed into the array, the patching logic throws an exception. It took me hours to understand why this was happening, but adding a container tag around the v-for tag (additional commented code in example) fixes the issue, but does prevent the default slot content from showing when the array is empty. Am I misunderstanding how this should work? I didn't find anything in the documentation that explains this behavior.
The text was updated successfully, but these errors were encountered: