You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During the initial mount the divs array will be populated correctly. However, there's a problem with updating if nodes are removed. Currently the example resets the array in onBeforeUpdate but that isn't quite enough to get it to work.
I've created a JSFiddle to try to demonstrate the problem using RC 5. I've followed the documentation example as closely as I could:
When one of the nodes is unmounted the template ref function still gets called, with an el of null. The result is that the divs array ends up with an extra null entry at the end that shouldn't be there.
I wasn't able to track down any documentation that explains what the expected behaviour of a function :ref is supposed to be. It was not immediately obvious to me that it would be passed null during unmounting. Assuming that isn't a bug it should probably be documented somewhere.
For the composition API example it's a small tweak to filter out the null values:
<divv-for="(item, i) in list" :ref="el => { if (el) divs[i] = el }">
The text was updated successfully, but these errors were encountered:
Thank you! I've fixed the code snippet with b9217d8 for now and will take a deeper look on what is passed on unmounting. Maybe it'd be better to fix on the source code rather than on docs 🤔
There's an example in the latest beta documentation showing how to use template refs with the composition API and
v-for
:Source Link
During the initial mount the
divs
array will be populated correctly. However, there's a problem with updating if nodes are removed. Currently the example resets the array inonBeforeUpdate
but that isn't quite enough to get it to work.I've created a JSFiddle to try to demonstrate the problem using RC 5. I've followed the documentation example as closely as I could:
https://jsfiddle.net/skirtle/8ak71rne/28/
When one of the nodes is unmounted the template
ref
function still gets called, with anel
ofnull
. The result is that thedivs
array ends up with an extranull
entry at the end that shouldn't be there.I wasn't able to track down any documentation that explains what the expected behaviour of a function
:ref
is supposed to be. It was not immediately obvious to me that it would be passednull
during unmounting. Assuming that isn't a bug it should probably be documented somewhere.For the composition API example it's a small tweak to filter out the
null
values:The text was updated successfully, but these errors were encountered: