Re: [w3c/webcomponents] Provide a lightweight mechanism to add styles to a custom element (#468)

> 1. fake-shadow-tree approach, allowing arbitrary selectors, and treat the stylesheet as it were defined at the beginning of fake-shadow-tree. That was originally proposed.
> 2. "Allowing only compound selector" approach, which can be explained without the concept of shadow tree. I proposed this.

Update from Google (on behalf of @hayatoito , @TakayoshiKochi, and @rakina), regarding both approaches.

- It's fine to have both approaches, however, our biggest concern is that web developers will not use 1, if we provides 2 too, in almost every cases.
  We don't want to ship a feature which is unlikely to be used.
- We still have a concern about the complexity of implementation of approach 1. The fake-shadow-root is a scary concept, both spec-wise and implementation-wise.
- Performance-wise, we believe that 2 is much faster than 1.
  We don't have data, so let us experiment both approaches. We'll update this thead once we can get more insights about the perforamance.
- In terms of developer's ergonomics, 2 looks better than 1. It's intuitive.

Regarding Ryosuke's [constraints](https://github.com/w3c/webcomponents/issues/468#issuecomment-379417095):

> 2. User stylesheet can't override the styles components set with or without !important.
> 3. Not have the ability to define the default style for a component as well as the !important style rules that can't be overridden by author styles (i.e. users of components).

It looks there is no feasible solution which satisfies the constraints, however, we think that is because constraints have a kind of contradiction, as such:

In 2, *users* (end-users) are honored over component-authors
In 3, *users* (component-users ) are *not* honored over component-authors.

Given custom element itself appears in user's markup, custom element itself can be considered *owned* by components users. If both (component-authors and component-users ) applies a style, component users should have the ability to override its default style.

This matches the Priority of Constituencies, I believe.
https://www.w3.org/TR/html-design-principles/#priority-of-constituencies

Note that this discussion doesn't apply for a style of an element in custom element's shadow tree.
The shadow tree should be basically *owned* by components authors, exclusively.

Give that, our experimenal plan for approach 2 is "Disallowing important declarations" in Custom UA style, as I explaiend in https://github.com/w3c/webcomponents/issues/468#issuecomment-378861530.

The remaining concern is that component users might override the style accidentally.
However, it's user's freedom and responsibility to avoid such a situation.
Users should have a full control of a style for all elements in their markup, basically.

Again, this claim doesn't apply for a style of elements in the custom element's shadow tree. The shadow tree should be *hidden* in any cases, basically, from selector matching perspective.

If component-authors don't like this behavior, in any case, there is always an option to use (fake) shadow root with a style, ":host !important". We can rescue them, but I think it is rare case.


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/468#issuecomment-389407203

Received on Wednesday, 16 May 2018 06:18:07 UTC