Skip to content
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

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

Open
yyx990803 opened this issue Dec 1, 2024 · 3 comments

Comments

@yyx990803
Copy link
Member

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
})()
@LittleSound
Copy link
Member

Has it been fixed?

@runyasak
Copy link

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.

@runyasak
Copy link

runyasak commented Feb 2, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants