-
Notifications
You must be signed in to change notification settings - Fork 375
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
Remove the constraint that slot can't have another slot as an ancestor #321
Comments
Unfortunately, this will make the situation extremely complex. e.g. How do you define the event path? The sibling nodes of the same shadow host would receive the same event. That would break the assumption of the event dispatching. Could you take a look at https://w3c.github.io/webcomponents/spec/shadow/#event-paths-example |
Also remember that a child of the shadow host could have a child node. It's not always a leaf node. |
There's nothing complicated here. Allowing nested slots would not cause a single event to be dispatched on siblings of a single parent node. For example, let us examine the following very simple shadow tree: <slot id=s1 name=foo>
<span id=s2>
<slot id=s3 name=bar></slot>
</span>
</slot> If an event were to fire at a node assigned to |
Yeah, having the fallback behavior is precondition for allowing the nesting. That's my point. Can we merge this issue to #317 ? |
I guess one of the motivations is that we don't need to check an ancestor of an slot element to know the given slot is valid one or not, in implementing Shadow DOM, right? |
Right. The motivation is to avoid the unnecessary validation in engines as well as making the behavior of slots more consistent. I don't think we should merge the issues. #317 is about enabling fallback contents. This issue is about not having the constraint. It's true that removing this constraint doesn't allow new use cases without allowing fallback contents for slots, but it still makes the behaviors of slot elements simpler and more consistent. |
Okay. We might have another option:
In this case, there is no point nesting slots, in terms of the composed tree, however, we remove the constraint anyway. I'm okay to this change as the first step. It doesn't look harmful. WDYT? |
Yeah, that's totally fine with me as a separate change. We'll see what happens with #317 in terms of fallback contents. |
I've removed the constraint at: be457d5. I'm now thinking that I can remove the condition further:
But this requires more investigation. That could be done as another issue. |
I think requiring the root node to be a shadow root is fine since slot element is really for shadow trees. But like you said, that's a separate issue if anything. |
After removing, I found that an issue of removing the constraint: <slot id=s1 name=foo>
<span id=s2>
<slot id=s3 name=bar></slot>
</span>
</slot>
Assuming that both s1 and s3 have a assigned node,
However, this wouldn't match the ancestor chain of the composed tree. :( e.g. see |
Ops. This issue is already there without removing the constraint. Suppose the an event fires at s2. :( As long as an event fires at a node in a document composed tree, we can live in a clean world. |
Yeah, in practical, there is no benefits. But no harmful, I guess. Removing the remaining condition would make the spec, and the implementation, simpler and more consistent, I guess. I will take a look this issue later, after we resolve the fallback issue, that's a necessary condition to remove the remaining condition. |
Now that I think about it more, I guess that constraint doesn't do anything since slots only get nodes assigned from its shadow host. So regardless of whether we have an explicit constraint or not, slots won't do anything if its root node isn't a shadow root. |
Yeah, there is no practical benefits. But we have a minor bonus. We can remove the following special behavior (at least we don't have to mention it):
If a slot is used in a document tree:
Thus, we can get a consistency. No special treatment is required for a slot in a document tree. |
Ah, right. Yes, that would be perfect! |
This seems like a completely unwarranted constraint:
This requirement introduces an inconsistency in the way slots are found in the shadow tree. e.g.
s3
instead ofs2
is the active slot in the example below despite of the facts2
appears befores3
in the tree order:It also prevents a rather compelling use case of nested slots once the fallback contents are supported by slot elements (see the issue #317). e.g.
The text was updated successfully, but these errors were encountered: