-
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 9 replies
-
based on your fragment of code, here is a working version, it shows the array in the order you want: |
Beta Was this translation helpful? Give feedback.
-
Got your point, the official grid.html example has similar issue: https://jsfiddle.net/gumde7nr/ first pass, you got: Bruce Lee, Chuck Norris, Jackie Chan, Jet Li A intended behaviour or a bug? |
Beta Was this translation helpful? Give feedback.
-
I think an error occurred when reusing components, I tried to fix it, it looks good at present work.(nooooooom@e2404f6) |
Beta Was this translation helpful? Give feedback.
-
This bug happen only on array update. If we take a look in v-for implementation, this is v-for initilisation. if (!mounted) {
blocks = childCtxs.map((s) => mountBlock(s, anchor))
mounted = true
} When updating, you can see below that the index is in reverse order and therefore the html mount is done in reverse. It explains the reverse order of the display. let i = childCtxs.length
while (i--) {
const childCtx = childCtxs[i]
const oldIndex = prevKeyToIndexMap.get(childCtx.key)
const next = childCtxs[i + 1]
const nextBlockOldIndex = next && prevKeyToIndexMap.get(next.key)
const nextBlock =
nextBlockOldIndex == null ? undefined : blocks[nextBlockOldIndex]
if (oldIndex == null) {
// new
nextBlocks[i] = mountBlock(
childCtx,
nextBlock ? nextBlock.el : anchor
)
} else {
// update
const block = (nextBlocks[i] = blocks[oldIndex])
Object.assign(block.ctx.scope, childCtx.scope)
if (oldIndex !== i) {
// moved
if (blocks[oldIndex + 1] !== nextBlock) {
block.insert(parent, nextBlock ? nextBlock.el : anchor)
}
}
}
} I made a dirty fix to verify this and it's working correctly. Note that this does not solve the problem with the grid example, which is another issue. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
This has been pushed to live now thanks to @nooooooom for the PR. |
Beta Was this translation helpful? Give feedback.
This has been pushed to live now thanks to @nooooooom for the PR.