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
{{ message }}
Repository navigation
Disallow attachShadow(...) for some elements. #110
changed the title [-]Enumerate the element names which don't support createShadowRoot().[/-][+]Enumerate the element names which don't support createShadowRoot(), instead of using binding property[/+]on Jun 11, 2015
changed the title [-]Enumerate the element names which don't support createShadowRoot(), instead of using binding property[/-][+]Enumerate the element names which don't support createShadowRoot(), instead of looking at the binding property[/+]on Jun 11, 2015
I'm thinking that the white list might be better than the black list for v1, given that, in practical, there are a limited number of HTML Elements for which createShadowRoot() makes sense.
The white list would be:
div, body, p, span and so on.
Please ignore my previous comment. Though I'm still wondering what is the best for v1, I'm going to enumerate the elements as the black list, as we planned.
Would the white list's "and so on" include things like input? Would that blacklist include things like input? I'm interested in using shadow roots on those elements.
Yes, I'm going to include <input> in the blacklist.
FYI. Blink supported createdShadowRoot() for <input>, however, we found that it would be hard to deliver the meaningful behavior to the users in such a case.
As of now, it doesn't make much sense to add a shadow root to <input> elements, AFAIK.
Hm, doesn't such hard-coded lists prevent innovation? I thought that the whole idea of web components is that developers can come up with new ideas and implement them without having to get browsers to adopt/change anything. With a hard-coded list you are preventing this. One now cannot enable createdShadowRoot on any element they would want/need, or for example, on all DOM elements?
I agree, however, it would be better to disable the support for these elements until we have a clear idea how the behavior should be for these elements.
AFAIR, one of the original motivations of this restriction is to achieve the interoperability.
@mitar yep. But those only work in Chrome. When trying to create a spec that works for multiple browsers, we realized that it's not possible to specify something interoperable (for now at least). Thus this change.
Given that the list of HTML elements is finite, a safelist vs. a blocklist is equivalent except for future changes to HTML. I would assume any future changes to HTML would coordinate with the shadow DOM spec, especially if we take the approach in whatwg/html#131 (or the safelist equivalent). So I think debating safelist vs. blocklist is not interesting. You should just come up with the list, in either form :).
EDIT: I see I didn't quite read to the bottom, please ignore my last sentence.
If I understand correctly the specs, I won't be able to attach shadow root to any standard SVG element and if I attach it to a custom element in SVG namespace then it won't be rendered on the screen anyway?
How Web Components are supposed to be useful with SVG given those limitations? You should at least allow attachShadow() on <g> elements or you should make custom elements in SVG namespace renderable.
Reacted by Bruno Gachie, Thomas Di Grégorio and Krzysztof Maczyński
As things stand, WebKit's implementation is not going to even define a custom SVG element in v1 (we'll only support direct inheritance from HTMLElement and other custom elements). We're taking baby steps and ensuring interoperable behavior across browsers instead of trying to address all uses cases in v1.
I have created a customized built-in map element, and I am continuously working to improve it and make it productions ready. It would be a major setback, I think, if the map element was not allowed to have a shadow root.
Is there by any chance a list with the disallowed elements and the reason for why they cannot hold a shadow tree? I understand that some elements already have browsers populate a shadow tree in them or they aren’t meant to have child content at all (e.g. input).
I’m particularly interested in why the details element is not allowed.
Edit: Just found this comment among the collapsed ones:
summary element also seems to create a user-agent shadow root in Blink and WebKit as well.
Why should it matter if UAs implement some elements using shadow DOM internally? It seems that should be an implementation detail not exposed in specs.
Why should it matter if UAs implement some elements using shadow DOM internally? It seems that should be an implementation detail not exposed in specs.
In theory, yes, in practice no. The fact these elements are implemented using shadow DOM would mean that we'd have to define exactly what happens when an author defined shadow root is attached, and we've never successfully done that. Furthermore, this poses a serious implementation challenge since having multiple shadow root isn't a thing in v1 API and its implementation. Supporting multiple generations of shadow roots in v0 had a huge implementation cost.
If and when a sensible proposal is made for defining what it means for these elements to have a shadow root, we can revisit this decision.
The fact these elements are implemented using shadow DOM would mean that we'd have to define exactly what happens when an author defined shadow root is attached
I imagined those UAs would be required to behave the same way as those which chose a different implementation strategy, not involving shadow DOM. Or is it a future compatibility concern whereby the UA's shadow tree in v2 would be somewhat exposed for integration with author's shadow trees? (Then it makes sense what I've recently read in some draft I cannot find, that using shadow DOM for implementing some elements is the default and some slots must be exposed even if an UA doesn't use shadow DOM internally – it must behave as if it did.)
Activity
[-]Enumerate the element names which don't support createShadowRoot().[/-][+]Enumerate the element names which don't support createShadowRoot(), instead of using binding property[/+][-]Enumerate the element names which don't support createShadowRoot(), instead of using binding property[/-][+]Enumerate the element names which don't support createShadowRoot(), instead of looking at the binding property[/+]hayatoito commentedon Jun 15, 2015
I'm thinking that the white list might be better than the black list for v1, given that, in practical, there are a limited number of HTML Elements for which createShadowRoot() makes sense.
The white list would be:
div, body, p, span and so on.
hayatoito commentedon Jun 15, 2015
Please ignore my previous comment. Though I'm still wondering what is the best for v1, I'm going to enumerate the elements as the black list, as we planned.
wh0 commentedon Jul 15, 2015
Would the white list's "and so on" include things likeWould that blacklist include things likeinput?input? I'm interested in using shadow roots on those elements.edit: oops, I didn't ignore that comment.
hayatoito commentedon Jul 16, 2015
Yes, I'm going to include
<input>in the blacklist.FYI. Blink supported createdShadowRoot() for
<input>, however, we found that it would be hard to deliver the meaningful behavior to the users in such a case.As of now, it doesn't make much sense to add a shadow root to
<input>elements, AFAIK.mitar commentedon Jul 16, 2015
Hm, doesn't such hard-coded lists prevent innovation? I thought that the whole idea of web components is that developers can come up with new ideas and implement them without having to get browsers to adopt/change anything. With a hard-coded list you are preventing this. One now cannot enable
createdShadowRooton any element they would want/need, or for example, on all DOM elements?hayatoito commentedon Jul 16, 2015
I agree, however, it would be better to disable the support for these elements until we have a clear idea how the behavior should be for these elements.
AFAIR, one of the original motivations of this restriction is to achieve the interoperability.
See also #102.
mitar commentedon Jul 16, 2015
That is interesting, because one of popular Shadow DOM tutorials use
createShadowRooton a now blacklisted element:mitar commentedon Jul 16, 2015
And one more tutorial using
input. I think there are already existing use cases shown.domenic commentedon Jul 16, 2015
@mitar yep. But those only work in Chrome. When trying to create a spec that works for multiple browsers, we realized that it's not possible to specify something interoperable (for now at least). Thus this change.
annevk commentedon Jul 16, 2015
It's not about use cases, it's about not knowing what it means.
49 remaining items
hayatoito commentedon Feb 1, 2016
Ops. I forgot to use safelist/blocklist in the commit message. My bad. Let me use safelist/blocklist from the next.
domenic commentedon Feb 1, 2016
Given that the list of HTML elements is finite, a safelist vs. a blocklist is equivalent except for future changes to HTML. I would assume any future changes to HTML would coordinate with the shadow DOM spec, especially if we take the approach in whatwg/html#131 (or the safelist equivalent). So I think debating safelist vs. blocklist is not interesting. You should just come up with the list, in either form :).
EDIT: I see I didn't quite read to the bottom, please ignore my last sentence.
jarek-foksa commentedon Feb 6, 2016
If I understand correctly the specs, I won't be able to attach shadow root to any standard SVG element and if I attach it to a custom element in SVG namespace then it won't be rendered on the screen anyway?
How Web Components are supposed to be useful with SVG given those limitations? You should at least allow attachShadow() on
<g>elements or you should make custom elements in SVG namespace renderable.rniwa commentedon Feb 6, 2016
As things stand, WebKit's implementation is not going to even define a custom SVG element in v1 (we'll only support direct inheritance from HTMLElement and other custom elements). We're taking baby steps and ensuring interoperable behavior across browsers instead of trying to address all uses cases in v1.
prushforth commentedon Aug 9, 2016
I have created a customized built-in map element, and I am continuously working to improve it and make it productions ready. It would be a major setback, I think, if the map element was not allowed to have a shadow root.
cyrilletuzi commentedon Oct 21, 2016
What about the
mainelement ? It's an element similar toheader,article... but it's missing in the current spec white list.annevk commentedon Oct 21, 2016
@cyrilletuzi could you file a new issue for that please?
kleinfreund commentedon Nov 28, 2018
Is there by any chance a list with the disallowed elements and the reason for why they cannot hold a shadow tree? I understand that some elements already have browsers populate a shadow tree in them or they aren’t meant to have child content at all (e.g.
input).I’m particularly interested in why the
detailselement is not allowed.Edit: Just found this comment among the collapsed ones:
rniwa commentedon Nov 28, 2018
detailselement has a user-agent shadow root in Blink and WebKit.ByteEater-pl commentedon Feb 26, 2020
Why should it matter if UAs implement some elements using shadow DOM internally? It seems that should be an implementation detail not exposed in specs.
rniwa commentedon Feb 26, 2020
In theory, yes, in practice no. The fact these elements are implemented using shadow DOM would mean that we'd have to define exactly what happens when an author defined shadow root is attached, and we've never successfully done that. Furthermore, this poses a serious implementation challenge since having multiple shadow root isn't a thing in v1 API and its implementation. Supporting multiple generations of shadow roots in v0 had a huge implementation cost.
If and when a sensible proposal is made for defining what it means for these elements to have a shadow root, we can revisit this decision.
ByteEater-pl commentedon Feb 26, 2020
I imagined those UAs would be required to behave the same way as those which chose a different implementation strategy, not involving shadow DOM. Or is it a future compatibility concern whereby the UA's shadow tree in v2 would be somewhat exposed for integration with author's shadow trees? (Then it makes sense what I've recently read in some draft I cannot find, that using shadow DOM for implementing some elements is the default and some slots must be exposed even if an UA doesn't use shadow DOM internally – it must behave as if it did.)
annevk commentedon Feb 29, 2020
The problem is defining what way they would have to behave. These elements are poorly understood standards-wise to begin with.
[Fix WICG#110] Enumerate the element names which don't support create…