Skip to content

Functional components with multiple roots don't render properly when used with v-for #8468

Closed
@kellym

Description

@kellym

Version

2.5.16

Reproduction link

https://jsfiddle.net/kb9x8rLf/

Steps to reproduce

Create a functional component that returns multiple root elements via an array, i.e.:

return [h('span'), h('span')];

Then use the functional component alongside v-for:

<my-component v-for="item in items" />

What is expected?

It should render the functional component as expected.

What is actually happening?

The rendered view contains "undefined" for each item in the array.


The JSFiddle demonstrates how wrapping the functional component in a <template> tag with the v-for directive fixes the issue, but the <template> tag should not be required for this. Oddly enough, there are some circumstances where it renders properly. In my use-case, I had no issues with the multiple root elements when I put the component inside a <table>, but when I wrapped the component with a <tbody> I ran into this issue I'm reporting.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions