docs icon indicating copy to clipboard operation
docs copied to clipboard

`It should be noted that the ref array does not guarantee the same order as the source array` - provide example (or remove)

Open jacekkarczmarczyk opened this issue 3 years ago • 2 comments

There's information in docs (https://vuejs.org/guide/essentials/template-refs.html#refs-inside-v-for) that the order of the elements of an array ref is not guaranteed.

It may restrain some developers from using <foo v-for="..." ref="someRef"> and make them search for another solution resulting in the correct order. However if the statement is valid only for very specific scenarios there should be some example(s) so that developers know whether their usecase would provide the correct order of elements or not.

If this is something that was just copied from Vue 2 and is not relevant any longer then it should be removed

jacekkarczmarczyk avatar Sep 15 '22 18:09 jacekkarczmarczyk

An example that yields the wrong order:

SFC Playground

The code responsible in Vue Core:

https://github.com/vuejs/core/blob/49023549257d8962c6e059808067b1b67b398534/packages/runtime-core/src/rendererTemplateRef.ts#L106

When a new item is added it just gets pushed onto the end.

skirtles-code avatar Jan 10 '23 10:01 skirtles-code

Perhaps instead, fix it so the order is guaranteed?

Giwayume avatar Apr 04 '24 20:04 Giwayume