Slotted elements missing in AST
See original GitHub issueDescribe the bug The AST for components using a slotted element is missing the slotted element.
Logs n/a
To Reproduce
Compile <Component><div slot='foo'></div></Component>
with Svelte 3.35.0 and look at the AST.
Expected behavior
The AST should be as it was in 3.34.0 and include the <div>
.
Stacktraces n/a
Information about your Svelte project: Svelte 3.35.0
Severity The right JS code looks like it’s still being generated, so this isn’t huge. But it will affect tooling. Medium-high I’d say.
Additional context This was brought to light by https://github.com/sveltejs/eslint-plugin-svelte3/issues/94
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (8 by maintainers)
Top Results From Across the Web
slotted() - CSS: Cascading Style Sheets - MDN Web Docs
The ::slotted() CSS pseudo-element represents any element that has been placed into a slot inside an HTML template (see Using templates and ...
Read more >::slotted() - CSS: Cascading Style Sheets
The ::slotted() CSS pseudo-element represents any element that has been placed into a slot inside an HTML template (see Using templates and slots...
Read more >litelement - styling nested elements within slotted elements
What am I missing so that I can apply the same style to the <a> element regardless of where it is within the...
Read more >Working with Shadow DOM - Lit.dev
Lit components use shadow DOM to encapsulate their DOM. Shadow DOM provides a way to add a separate isolated and encapsulated DOM tree...
Read more >Custom Element Best Practices - web.dev
Custom elements let you construct your own HTML tags. ... Use <slot> to project light DOM children into your shadow DOM.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I want to point out that language tools (with svelte2tsx), the prettier plugin and the eslint plugin all rely on the AST to some extend, so while the API is technically private, it’s still something we can’t change it at will.
oh no 😦
I rearranged the children of the
InlineComponent
node to wrap<element slot="xxx">
,<Component slot="xxx">
with<svelte:fragment slot="xxx">
, and all the remaining elements with<svelte:fragment>
In this step, I mutated the AST node. (L114)
https://github.com/sveltejs/svelte/blob/1d6e20f2a967aebfa9c3eab769ca587345169632/src/compiler/compile/nodes/InlineComponent.ts#L109-L150
So, I have 2 options from here:
<svelte:fragment>
insertedast.html
before mutation as wellhttps://github.com/sveltejs/svelte/blob/2925a00eff74414d5bc1d28a492e54ff827d00a6/src/compiler/compile/Component.ts#L117-L124
or rather