-
Notifications
You must be signed in to change notification settings - Fork 11
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
[RRFC] SlotController #7
Comments
As mentioned in shoelace-style/shoelace#778, SlotController might be useful as a way of detecting whether slots have assigned elements in shadow DOM. It would require SSR-specific code in SlotController, which we don't quite have a way to do yet, and probably specific support to parse children or notifiy on children with parts in lit-ssr. cc @aomarks |
Here is a prototype of a slightly different take on this same idea, called SlottableController. The difference is that the elements tracked are host slottable candidates and not actually assigned nodes. This makes it easier to conditionally render slots and perform manual slot assignment based on the existence of child elements. It also integrates well with the slottable-request protocol. The API prototyped for the controller includes:
|
@sorvell would you say that's a polyfill or companion to imperative slotting? One thing I've wanted with imperative slotting is a helper that takes a callback on new child elements being added and returns a slot to assign too, as well as maybe handling serializing things to named slots for SSR. |
It's not a polyfill, it's a helper. Imperative slotting is well supported now =). |
Motivation
Moved from lit/lit#2693
There are a few common patterns for using slots that could be nicely wrapped up in a reactive controller:
Example
We could make a SlotController(s) to help.
How
See https://gist.github.com/justinfagnani/a90eefb8da6bbfa4250a46732a8e5fbc
Current Behavior
Libraries write their own slot controller, like https://github.com/shoelace-style/shoelace/blob/next/src/internal/slot.ts or users use
slotchange
.Desired Behavior
It's easier.
References
The text was updated successfully, but these errors were encountered: