let x-if add multiple root nodes #2052
Replies: 3 comments 4 replies
-
|
I believe the current behaviour is mainly for 2 reasons:
None of them is a real blocker for V3, though. Theoretically, you can also implement your own directive supporting multiple children for your own projects (you just need a good name, maybe x-when). |
Beta Was this translation helpful? Give feedback.
-
|
Is there any progress on this issue? Conditional blocks with multiple elements is a pain currently. |
Beta Was this translation helpful? Give feedback.
-
|
I started migrating a huge codebase from Vue to Alpine and after 2 hours hit a wall - realizing all template tags can have exactly one root element for some weird reason. This broke all my CSS selectors (because there's a dummy extra tag everywhere). Too much friction. Staying on Vue, I guess :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It'd be nice to no longer need shim elements or a lot of code duplication to bring in multiple sibling nodes with an x-if template element. The following is a somewhat common scenario: a view selector within a page with computationally heavy styles and scripts that we don't want running when the view isn't loaded. It could be this easy:
If this example were possible it'd be much easier to manipulate layers (z-index) for lightbox effects or style div.view using a grid. Where using a shim element throws off the hierarchy or requires much more html to be duplicated inside the template or the use of many more templates like so:
All the additional lines and duplicated code just makes things brittle and more error prone.
Beta Was this translation helpful? Give feedback.
All reactions