Skip to content

Disallow attachShadow(...) for some elements. #110

Closed

Description

@hayatoito

See
9b65780#commitcomment-11603549 for the context.

Activity

  1. 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
  2. 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
  3. hayatoito commented on Jun 15, 2015

    @hayatoito
    ContributorAuthor

    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.

  4. hayatoito commented on Jun 15, 2015

    @hayatoito
    ContributorAuthor

    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.

  5. wh0 commented on Jul 15, 2015

    @wh0

    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.

    edit: oops, I didn't ignore that comment.

  6. hayatoito commented on Jul 16, 2015

    @hayatoito
    ContributorAuthor

    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.

  7. mitar commented on Jul 16, 2015

    @mitar

    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?

  8. hayatoito commented on Jul 16, 2015

    @hayatoito
    ContributorAuthor

    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.

  9. mitar commented on Jul 16, 2015

    @mitar

    That is interesting, because one of popular Shadow DOM tutorials use createShadowRoot on a now blacklisted element:

    var host = document.querySelector('button');
    var root = host.createShadowRoot();
    root.textContent = 'こんにちは、影の世界!';
    
  10. mitar commented on Jul 16, 2015

    @mitar

    And one more tutorial using input. I think there are already existing use cases shown.

  11. domenic commented on Jul 16, 2015

    @domenic
    Collaborator

    @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.

  12. annevk commented on Jul 16, 2015

    @annevk
    Collaborator

    It's not about use cases, it's about not knowing what it means.

  13. 49 remaining items

  14. hayatoito commented on Feb 1, 2016

    @hayatoito
    ContributorAuthor

    Also, we should use safelist/blocklist rather than whitelist/blacklist I think. See whatwg/html#265 for rationale.

    Ops. I forgot to use safelist/blocklist in the commit message. My bad. Let me use safelist/blocklist from the next.

  15. domenic commented on Feb 1, 2016

    @domenic
    Collaborator

    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.

  16. jarek-foksa commented on Feb 6, 2016

    @jarek-foksa

    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.

  17. rniwa commented on Feb 6, 2016

    @rniwa
    Collaborator

    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.

  18. prushforth commented on Aug 9, 2016

    @prushforth

    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.

  19. cyrilletuzi commented on Oct 21, 2016

    @cyrilletuzi

    What about the main element ? It's an element similar to header, article... but it's missing in the current spec white list.

  20. annevk commented on Oct 21, 2016

    @annevk
    Collaborator

    @cyrilletuzi could you file a new issue for that please?

  21. kleinfreund commented on Nov 28, 2018

    @kleinfreund

    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.

  22. rniwa commented on Nov 28, 2018

    @rniwa
    Collaborator

    details element has a user-agent shadow root in Blink and WebKit.

  23. ByteEater-pl commented on Feb 26, 2020

    @ByteEater-pl

    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.

  24. rniwa commented on Feb 26, 2020

    @rniwa
    Collaborator

    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.

  25. ByteEater-pl commented on Feb 26, 2020

    @ByteEater-pl

    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.)

  26. annevk commented on Feb 29, 2020

    @annevk
    Collaborator

    The problem is defining what way they would have to behave. These elements are poorly understood standards-wise to begin with.

  27. added a commit that references this issue on Jul 30, 2025
    a596088
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions