-
Notifications
You must be signed in to change notification settings - Fork 27
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
Allowed children for slots #46
Comments
I also would need that as info for my designer (https://github.com/node-projects/web-component-designer) |
CSS selectors might be insufficient here. The HTML specification has a concept of "content-models" to express this for built-in elements: https://html.spec.whatwg.org/multipage/dom.html#content-models This has categories like "Interactive content" and "Palpable content" that would only be describable with large lists of tag name selectors. And I don't see how class selectors and attribute selectors will be generally useful for this feature. I don't know of elements that say that a slot can only contain with a certain class. I have seen elements that can only accept things like: specific elements, a single element, elements that have implement a certain JS interface, and elements that fire or listen to specific events. I'm not sure how we describe all that, and it's not easily machine generated. I think we should collect examples of child restrictions first. |
I would like to add that we've found use cases for both directions of restrictions:
It seems that the
This is a really good argument against css selectors! It might make sense to support a "CSS selector inspired" syntax with wildcard
A great place to look for inspiration:
|
There could also be a restriction of how many elements could be added, and how many of wich type. Also, there could be named slots, maybe we also should have a way wich names exit and wich elements could be used inside of them. At hte moment I solved it like this in my designer (https://node-projects.github.io/web-component-designer-demo/index.html) - if a custom-element has a slot, it could be a container, if not, not |
This isn't true always either, because elements without a shadow root show their contents, and even with a shadow root and no slot, the child elements can hold state, fire events, etc. |
Both standard components (e.g.
table
,tr
,td
,dl
,dd
) and web components (e.g.tab-panels
,tab-panel
) have implicit constraints on what elements are allowed as children, and also what are allowed as parents.I would propose that a slot description should also include a way to codify this.
For example:
The text was updated successfully, but these errors were encountered: