-
Notifications
You must be signed in to change notification settings - Fork 382
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
Disallow attachShadow(...) for some elements. #110
Comments
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: |
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. |
edit: oops, I didn't ignore that comment. |
Yes, I'm going to include FYI. Blink supported createdShadowRoot() for As of now, it doesn't make much sense to add a shadow root to |
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 |
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. |
That is interesting, because one of popular Shadow DOM tutorials use
|
And one more tutorial using |
@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. |
It's not about use cases, it's about not knowing what it means. |
I'm not sure I follow what the behavioral problem is with supporting createShadowRoot on the black-listed elements. Care to enumerate? Don't you simply loose interactivity + rendering? |
What it means in Chrome then? :-) |
@travisleithead well for one it depends if user agents use shadow trees to implement those elements. And I think also currently it depends on inherited shadow trees, which we removed for v1. Do you have some kind of working prototype how this would work? |
No prototype yet, but just thinking about what the user-expectation would be. Obviously native rendering would be hidden, but would event handlers still trigger behavior on the element? e.g., bubbling/capture of click event, would it trigger file-upload dialog? I think the expectations would be not to have those native behaviors get triggered. |
FYI. In blink, That means createShadowRoot() works for AFAIR, |
@travisleithead until you have defined that processing model, and patched these existing elements in the specification to be aware of shadow DOM and what it means for their processing model, I think supporting anything here is a non-starter. |
Hm, what about then providing a blacklist of elements which cannot support insertion points? |
This is what was committed here. |
What about extending and then styling |
Styling of form controls is still a largely unsolved problem. We need someone capable with a sponsor of sorts to sort through that. |
I don't think we should have a fixed list of elements as the normative text as we might be adding more elements in the future. I think it's better for the normative text to refer to the binding property and then add a non-normative text enumerating the currently known list of elements with the binding property. |
We should just revive the list once we add a new element like that. Alternatively we say in HTML that these elements set some kind of flag that this algorithm uses, but that seems more involved. |
@annevk it turns out HTML kind of does set a flag, but it sets it in a strange way, by in the UA stylesheets section saying that elements have a This is all done in terms of a not-implemented spec, http://www.w3.org/TR/becss/. This seems pretty weird and maybe something that should be fixed in HTML to go with a more flag-like approach... |
I'd like to move this issue forward. As the first step, can we agree on having a white list? It seems the safest approach to me.
We can expand this white list anytime if we can agree on adding an element to the list when such a request is coming. If we find that having a white list is hard to maintain, we can switch to a black list in the future. |
A whitelist is a safe approach, but from reading this thread it would seem the only elements that really need blacklisting are those that don't allow html / text content. I've many times created custom buttons where I'm projecting content into them, even if it's only text-content. I've avoided using What about blacklisting void elements and allowing everything else? |
@treshugart that does not work, e.g., @hayatoito why can we not include more elements we know are not problematic as I suggested in #110 (comment)? I guess I don't feel particularly strongly though. Also, we should use safelist/blocklist rather than whitelist/blacklist I think. See whatwg/html#265 for rationale. |
I was thinking about another approach. It is a bit tricky to explain, but more flexible. What if we support Shadow Root creation on all elements, but with blocklist which contains elements that might not change their internal structure. What I mean is that for elements like This is a bit tricky, but spec already contains similar tricks like self-closing HTML tags which are basically list of those special elements and everything else works by general rules. It would be really sad if styling postponed to v2 of this spec. |
@nazar-pc if it doesn't affect how they are constructed, it will not affect rendering either. That is somewhat closely intertwined. |
@hayatoito this seems good to me (modulo comments I made on the commit). We should probably just ask for new issues if folks want to expand the safelist. |
@annevk, then suggestion is something like:
I'm really trying to find replacement for |
I see. Let me close this issue. Please feel free to file a new issue if folks want to expand the safelist. |
Ops. I forgot to use safelist/blocklist in the commit message. My bad. Let me use safelist/blocklist from the next. |
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 |
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. |
What about the |
@cyrilletuzi could you file a new issue for that please? |
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. I’m particularly interested in why the Edit: Just found this comment among the collapsed ones:
|
|
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. |
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.) |
The problem is defining what way they would have to behave. These elements are poorly understood standards-wise to begin with. |
See
9b65780#commitcomment-11603549 for the context.
The text was updated successfully, but these errors were encountered: