-
Notifications
You must be signed in to change notification settings - Fork 789
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
Add Fragment to @stencil/core #1151
Comments
This comment has been minimized.
This comment has been minimized.
@simonhaenisch Yeah, this isn't a web component, it's just a JSX tag! So, no dash. |
@michaelauderer we would like to be able to use the short-syntax:
but looks like it's not supported by typescript outside React, "React" is hardcoded into typescript: microsoft/TypeScript#20469 |
@manucorporat Yes, this would be even nicer, but until we get support from typescript it would be great to at least include the Fragment element. |
Is there any update on this? Not having full control over markup is a pretty drastic limitation. Particularly now with CSS grid, markup structure matters for layout and I can't just have unnecessary divs around everything. Pretty sure LitElement doesn't have this drawback. |
@o-t-w not sure what you mean because this doesn't limit your ability to have full control over your markup? It's just syntactic sugar (that indeed increases readability a lot), i. e. you can already either use arrays or add the suggested |
@o-t-w For now, I've already built a solution for it here: https://github.com/michaelauderer/stencil-fragment If someone can point out where it belongs in the Stencil repository, I'll make a PR. (@manucorporat, any thoughts?) |
Stencil 1.0 introduces a new |
@manucorporat
|
I, too would like to see Kudos to @auderer for providing exactly that! |
Looks like I celebrated too soon. I misunderstood Fragment to also have an InnerHTML property somehow causing that content to magically be rendered. Instead, it looks like it's just a container that renders child elements. It makes sense that it doesn't do what I expected with InnerHTML. |
As @auderer said and did in his Github project, it is just a one-liner:
Why wouldn't be possible to add it in @stencil/core? |
Actually, microsoft/TypeScript#38720 was just merged so we can use the |
Ok. Good news. But in the meanwhile, it would be nice to have a |
In the meanwhile you could also just add your one-liner into your project(s) 😬 Feel free to open a PR though, but no promises that it'll be merged (up to the maintainers). Especially with a better solution in sight already. |
No worries. I wasn't going to wait before an action on the codeline would be made. I know how slow an organization is :) On top of that, majority of issues are closed as soon as possible even if the issue exists. We'll see what's happening with the new |
Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Stencil, please create a new issue and ensure the template is fully filled out. Thank you for using Stencil! |
Stencil version:
I'm submitting a:
[ ] bug report
[x] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/
Current behavior:
Rendering multiple elements requires either a wrapping div or returning an array. Returning an array avoids rendering an unwanted
<div>
, but array format with JSX is hard to read and work with, especially in larger components.Expected behavior:
Just like React, you could wrap multiple elements in a
<Fragment>
tag.Steps to reproduce:
Without fragment:
Related code:
With fragment:
Other information:
This is an extremely simple feature to add, I'm just not sure where it should go in the stencil repository.
The working Fragment code is literally just this one line:
Or without ES6:
Used as a JSX element, this simply renders the children without rendering an arbitrary wrapping element.
I made a package here to provide this feature, but it would be fantastic if it were available in @stencil/core. People coming from React will love this.
If someone can advise me where in the repo to add this code, I would be happy to make the PR myself.
The text was updated successfully, but these errors were encountered: