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
Allow functional components to have multiple root elements #1168
Comments
This would make creating functional components a lot easier 🙂 |
+1 |
It would be very useful especially in cases when you want to create a component for definition lists.
|
This issue relates to |
@stalniy which package / repository are you talking too? I have no |
@mathroc I'm saying that the fix should be done in vue template compiler here (https://github.com/vuejs/vue/blob/dev/src/compiler/parser/index.js#L198) and not in vue loader |
Looks like Vue itself already supports multiple roots in functional components. |
@nolde OP is aware of that, his request us about functional templates. |
@LinusBorg , my point was about @stalniy mentioning that this issue should be fixed in vue-template-compiler instead of vue-loader. If vue already supports that in functional components, it probably supports that in the template compiler already. If it doesn't, then those are two different issues. |
+1. Found myself needing this to make effective use of CSS grids (especially while display: contents isn't well supported). I had to work around the limitation by merging what would have been sub-components into a single more complex component. |
Tip for people having this issue: use JSX. The JSX loaders for vue support multiple roots by returning an array of components/elements, and it also works around the issue of not being able to register local components. It is perfect for functional components. |
I also am facing issues, even in the same case @atorscho, trying to create something like this:
|
@stalniy Note that links without a commit will not match the intended line-number in future. |
What problem does this feature solve?
As discussed in vuejs/vue#7088 multiple root elements are not currently possible in Vue components, with @LinusBorg stating that multiple root elements will not be supported (in the general case) any time soon.
The exception to this is for functional components, where multiple root elements are allowed. Here's a jsfiddle from @trusktr showing it, though using a render function:
https://jsfiddle.net/b049qboe/1/
This feature would allow multiple root elements in elements used in single-file components. Vue-loader 14.1.1 produces the following error in this scenario:
What does the proposed API look like?
In a single-file component:
The text was updated successfully, but these errors were encountered: