vuejs/vue-vapor

[bug] createComponent singleRoot check should not be `true` when it has `v-for`

yyx990803 opened this issue · 3 comments

Given this

<Comp v-for="i in 10000" />

Current codegen (the 4th argument true indicates a child component that is also the root of the parent):

return ((_ctx) => {
  const n0 = _createFor(() => (10000), (_ctx0) => {
    const n2 = _createComponent(Comp, null, null, true)
    return n2
  })
  return n0
})()

Expected:

return ((_ctx) => {
  const n0 = _createFor(() => (10000), (_ctx0) => {
-   const n2 = _createComponent(Comp, null, null, true)
+   const n2 = _createComponent(Comp)
    return n2
  })
  return n0
})()

Has it been fixed?

I've noticed that if there is only a single root element, the fourth argument is included.
However, if there are multiple elements, just simply add a single <div />, there is only one argument which aligns with our expectations.

If I’m mistaken or misunderstanding something, please let me know.

Single Element

Image

Multiple Elements

Image

Would it be possible to assign this issue to me? I’d love to contribute as soon as possible.

@LittleSound I have created a PR to resolve this issue, but it is still a work in progress.
Please review my PR: #305.