You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I don't think that should happen. In the world where re-distribution is explicit, there is no point in stripping out slot elements. It's better to treat a slot element like any other element and re-distribute it on its entirely. This will make the distribution/composition algorithm much simpler and allows slot element to be styled properly.
It would be problematic if they are projected inside the <slot>. In that case one couldn't, for example, project elements into an element that has display: flex.
<x-b>
SR
<div style="display: flex;"><slot></slot></div>
<div>flex item?</div>
I'd like to treat a slot, as well as an insertion point, asDocumentFragment, as ShadowRoot actually is. That has been in my mental model for a long time. By considering both as DocumentFragment, everything became clear to me.
I guess someone doesn't like a slot element being left in the document composed tree, given a shadow root is not left in the document composed tree.
IMO, a slot, and an old insertion point as well as a shadow root, should not be on any more than needed to support the distribution and the composition mechanism.
It would be problematic if they are projected inside the <slot>. In that case one couldn't, for example, project elements into an element that has display: flex.
<x-b>
SR
<div style="display: flex;"><slot></slot></div>
<div>flex item?</div>
I see. That's a pretty good argument for keeping the currently spec'ed behavior although it feels like we're working around the limitation of CSS.
If we had a new display type like display: ignore which replaces a node with its children for the purpose of box generations, we wouldn't need to do this, right?
One thing I don't like about the current model is the discrepancy between the composed tree as exposed to CSS and the tree event dispatching takes place. Namely, the event path will include the slot element that is a deep ancestor of the target.
I'd like to treat a slot, as well as an insertion point, asDocumentFragment, as ShadowRoot actually is. That has been in my mental model for a long time. By considering both as DocumentFragment, everything became clear to me.
I don't understand what you mean by this. A slot element is an element so it certainly can't be a document fragment.
Moreover, as things stand, the concept of "slot" isn't well defined in the spec. It's a "defined location" according to the spec but there are no definitions of "defined"-ness or what a "location" is. It could be a (node, offset) pair like a boundary point or it could be a node. Whatever it is, it needs to be precisely defined. See issues #306 and #307.
I don't think we want to do this just for the styling use cases mentioned here. I think we just need to set display: contents as the default sheet sheet on slot elements as follows and that should address both use cases mentioned here.
slot{display: contents;}
To put it another way, the composed tree is only useful to CSS box generation and the current distribution algorithm is trying to avoid box generation for slot element manually. And I'm saying that it's not necessary or desirable since box generation is inherently a CSS concern and should be dealt as such.
We can preserve the behavior of not generating boxes (so that tables, flex boxes, ec... work) without having to do it manually in the algorithm by simply relying on a CSS feature such as display: contents or a new concept in CSS if one is needed.
One huge benefit of this approach is that the author can then override display property, e.g. to show borders around slot elements, if they wanted to, and removes one more magic from shadow DOM.
One huge benefit of this approach is that the author can then override display property, e.g. to show borders around slot elements, if they wanted to, and removes one more magic from shadow DOM.
FYI, we can get this benefit by wrapping a slot with an arbitrary element, like:
Right, but that's not really my point. The benefit of making this behavior reliant on CSS is that we'll decouple shadow DOM's distribution algorithm from the matter of box generation so that authors can figure it as they wish.
I think we should try this. We've attempted this before, and failed for a reason I can't remember. I would love to explain <slot> as just a UA style that's slot { display:contents; }.
I see. I think one good news is this is an implementation detail because users can't see the difference unless users try to style <slot> elements, right? Both approaches should have the same result, I think, because we won't expose an API for composed tree traversal.
How can we trust the feature of {display: contents}? Can we be 100% sure this will be successful? It looks there is no other spec which bets on its success, AFAIK. Only Shadow DOM looks the early adapter.
Suppose that we support "a slot in a flat tree" in the spec, and developers start to style a slot element, that's un-reversible change.
Later, when we find "{display: contents}" is not a thing, it's too late. We can not change the behavior without breaking the Web site.
Thus, I have to be careful to add a slot in a flat tree. If we support it, that means that Shadow DOM will fail if {display: contents} fails.
Is there any significant benefit of adding a slot in a flat tree, which is worth having such a great risk?
Note that we can support "slots in a flat tree" anytime later when we can feel "{display: contents}" is widely accepted.
I am not opposing to "slots in a flat tree", but I am afraid that it's too risky today, and today is not the day.
@tabatkins, WDTY? Do you have a good feeling that "{display: contents}" will become successful??
In general, it's a good idea to minimize the number of new "magics" we introduce to the Web. Being able to describe/de-sugar slot element's behavior in terms of display: contents would be "explaining" the platform and "building on top of primitives". Introducing a shadow-DOM specific CSS box generation mechanism is anti-pattern in this regard (against the Extensible Web Manifest).
On more concrete examples, I already hit an interoperability problem with Chrome whereby which it doesn't respect display: none on slot elements whereas WebKit did. Chrome's behavior of ignoring display:none was rather surprising for me as an author. In addition, having to use :slotted(*) because styles on slot elements would be ignored has been really annoying.
Then, it looks reasonable to support "add slots in a flat tree" with UA-style "slot { display:contents; }" in the spec. I'll update the spec.
Since Blink has not supported "display: contents" yet and its engine requires a huge rewrite to support "a slots in a flat tree", Blink's initial implementation of v1 will not fully respect it.
If someone has a concern about this decision, please let us know that.
Looking at WebKit I think right now slotted elements inherit from the parent of the <slot>, and webkit only respects display: none. That is doing slot { display: block; } has no effect.
I'm very hesitant to ship with matching behavior, it doesn't seem like that's how display: contents was supposed to work. display: contents also has implications, for example are counter increments considered when declared on the slot? What about quoting level? Does slot::before and slot::after work? does display: contents disable ::before? (I hope so). What about slot::first-line ?
I'd like to work out the details before we commit to making display: contents be a thing, and slot having a dependency on that technology. The current system is easy to explain, is just gone by the time styles are computed. There's no subtle rules for what does and does not apply.
Looking at WebKit I think right now slotted elements inherit from the parent of the , and webkit only respects display: none. That is doing slot { display: block; } has no effect.
I'm very hesitant to ship with matching behavior, it doesn't seem like that's how display: contents was supposed to work.
Correct, that is a broken implementation. Firefox has, afaik, a real implementation of display:contents.
display: contents also has implications, for example are counter increments considered when declared on the slot? What about quoting level? Does slot::before and slot::after work? does display: contents disable ::before? (I hope so). What about slot::first-line ?
Counters work on the element tree; they're not disturbed by box-tree manipulation. (If they were, then the 'order' property would mess with them too.) Quotes aren't very specific (they're defined by language lingering from CSS2, when we were much less explicit about the element/box/fragment divisions), but they should work the same. Pseudo-elements still generate as normal.
Telecom agreement: We'd spec this as display: contents. While there are unknowns with respect to its behavior, and there is disagreements within Google regarding this feature, it seems okay to use this given WebKit and Gecko are implementing this feature in near future.
Activity
sorvell commentedon Sep 2, 2015
Where would the distributed nodes be projected?
It would be problematic if they are projected inside the
<slot>. In that case one couldn't, for example, project elements into an element that hasdisplay: flex.hayatoito commentedon Sep 2, 2015
Thanks for the feedback.
I'd like to treat a slot, as well as an insertion point, as
DocumentFragment, as ShadowRoot actually is. That has been in my mental model for a long time. By considering both asDocumentFragment, everything became clear to me.I guess someone doesn't like a slot element being left in the document composed tree, given a shadow root is not left in the document composed tree.
IMO, a slot, and an old insertion point as well as a shadow root, should not be on any more than needed to support the distribution and the composition mechanism.
rniwa commentedon Sep 2, 2015
I see. That's a pretty good argument for keeping the currently spec'ed behavior although it feels like we're working around the limitation of CSS.
If we had a new display type like
display: ignorewhich replaces a node with its children for the purpose of box generations, we wouldn't need to do this, right?One thing I don't like about the current model is the discrepancy between the composed tree as exposed to CSS and the tree event dispatching takes place. Namely, the event path will include the slot element that is a deep ancestor of the target.
rniwa commentedon Sep 2, 2015
I don't understand what you mean by this. A slot element is an element so it certainly can't be a document fragment.
Moreover, as things stand, the concept of "slot" isn't well defined in the spec. It's a "defined location" according to the spec but there are no definitions of "defined"-ness or what a "location" is. It could be a (node, offset) pair like a boundary point or it could be a node. Whatever it is, it needs to be precisely defined. See issues #306 and #307.
hayatoito commentedon Sep 2, 2015
Thanks. I think we can close this issue. Please feel free to re-open this if required.
Let me address some comments as separate issues, like #306.
One more note I can add here is that we might want to support the following use case in the future:
In this case, I guess no one is pleasant that
<slot>would appear between<table>and<thead>in the composed tree.rniwa commentedon Sep 2, 2015
I don't think we want to do this just for the styling use cases mentioned here. I think we just need to set
display: contentsas the default sheet sheet on slot elements as follows and that should address both use cases mentioned here.To put it another way, the composed tree is only useful to CSS box generation and the current distribution algorithm is trying to avoid box generation for slot element manually. And I'm saying that it's not necessary or desirable since box generation is inherently a CSS concern and should be dealt as such.
We can preserve the behavior of not generating boxes (so that tables, flex boxes, ec... work) without having to do it manually in the algorithm by simply relying on a CSS feature such as
display: contentsor a new concept in CSS if one is needed.One huge benefit of this approach is that the author can then override display property, e.g. to show borders around slot elements, if they wanted to, and removes one more magic from shadow DOM.
hayatoito commentedon Sep 3, 2015
FYI, we can get this benefit by wrapping a slot with an arbitrary element, like:
Before:
After:
rniwa commentedon Sep 3, 2015
Right, but that's not really my point. The benefit of making this behavior reliant on CSS is that we'll decouple shadow DOM's distribution algorithm from the matter of box generation so that authors can figure it as they wish.
dglazkov commentedon Sep 3, 2015
I think we should try this. We've attempted this before, and failed for a reason I can't remember. I would love to explain
<slot>as just a UA style that'sslot { display:contents; }.hayatoito commentedon Sep 3, 2015
I see. I think one good news is this is an implementation detail because users can't see the difference unless users try to style
<slot>elements, right? Both approaches should have the same result, I think, because we won't expose an API for composed tree traversal.annevk commentedon Sep 3, 2015
Isn't
deepPathusing the composed tree?43 remaining items
[-]Composition Algorithm shouldn't unwrap slots[/-][+]Slots in a flat tree[/+]hayatoito commentedon Mar 28, 2016
My biggest concerns are:
{display: contents}? Can we be 100% sure this will be successful? It looks there is no other spec which bets on its success, AFAIK. Only Shadow DOM looks the early adapter.Later, when we find "{display: contents}" is not a thing, it's too late. We can not change the behavior without breaking the Web site.
Thus, I have to be careful to add a slot in a flat tree. If we support it, that means that Shadow DOM will fail if
{display: contents}fails.Is there any significant benefit of adding a slot in a flat tree, which is worth having such a great risk?
Note that we can support "slots in a flat tree" anytime later when we can feel "{display: contents}" is widely accepted.
I am not opposing to "slots in a flat tree", but I am afraid that it's too risky today, and today is not the day.
@tabatkins, WDTY? Do you have a good feeling that "{display: contents}" will become successful??
rniwa commentedon Mar 28, 2016
In general, it's a good idea to minimize the number of new "magics" we introduce to the Web. Being able to describe/de-sugar slot element's behavior in terms of
display: contentswould be "explaining" the platform and "building on top of primitives". Introducing a shadow-DOM specific CSS box generation mechanism is anti-pattern in this regard (against the Extensible Web Manifest).rniwa commentedon Mar 28, 2016
On more concrete examples, I already hit an interoperability problem with Chrome whereby which it doesn't respect
display: noneon slot elements whereas WebKit did. Chrome's behavior of ignoringdisplay:nonewas rather surprising for me as an author. In addition, having to use:slotted(*)because styles on slot elements would be ignored has been really annoying.tabatkins commentedon Mar 28, 2016
display: contentsis useful on the CSS side for a number of things; Shadow DOM is only one of them.I can't say whether it will succeed or not, as that depends on browser vendors implementing it. That said, I think Firefox has done so.
hayatoito commentedon Mar 31, 2016
@tabatkins, thanks.
Can I confirm one more thing? Does the following HTML work as expected (from the view of the spec)?
This is the raised concern from @sorvell in #308 (comment).
tabatkins commentedon Mar 31, 2016
Yes, it works as expected, per spec. I think this works in Firefox right now if you want to test it.
hayatoito commentedon Mar 31, 2016
@tabatkins , thanks. I appreciate that.
Then, it looks reasonable to support "add slots in a flat tree" with UA-style "slot { display:contents; }" in the spec. I'll update the spec.
Since Blink has not supported "display: contents" yet and its engine requires a huge rewrite to support "a slots in a flat tree", Blink's initial implementation of v1 will not fully respect it.
If someone has a concern about this decision, please let us know that.
esprehn commentedon Apr 1, 2016
Looking at WebKit I think right now slotted elements inherit from the parent of the
<slot>, and webkit only respects display: none. That is doingslot { display: block; }has no effect.I'm very hesitant to ship with matching behavior, it doesn't seem like that's how display: contents was supposed to work. display: contents also has implications, for example are counter increments considered when declared on the slot? What about quoting level? Does slot::before and slot::after work? does display: contents disable ::before? (I hope so). What about slot::first-line ?
I'd like to work out the details before we commit to making display: contents be a thing, and slot having a dependency on that technology. The current system is easy to explain, is just gone by the time styles are computed. There's no subtle rules for what does and does not apply.
tabatkins commentedon Apr 1, 2016
Correct, that is a broken implementation. Firefox has, afaik, a real implementation of display:contents.
All defined by https://drafts.csswg.org/css-display/#valdef-display-contents.
Counters work on the element tree; they're not disturbed by box-tree manipulation. (If they were, then the 'order' property would mess with them too.) Quotes aren't very specific (they're defined by language lingering from CSS2, when we were much less explicit about the element/box/fragment divisions), but they should work the same. Pseudo-elements still generate as normal.
rniwa commentedon Apr 5, 2016
Telecom agreement: We'd spec this as
display: contents. While there are unknowns with respect to its behavior, and there is disagreements within Google regarding this feature, it seems okay to use this given WebKit and Gecko are implementing this feature in near future.Slot elements should support fallback contents
Fix WICG#308: Slots in a flat tree