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

I think it would be worth reconsidering the cascading order of "Custom Element Default Style" of the proposal.

Currently, it is defined as:

> The default styles will be treated as if they are the first stylesheets in the custom element's shadow root's stylesheets, if exists

however, we've seen several feedback arguing this rule is [*unfortunate*](https://github.com/w3c/webcomponents/issues/468#issuecomment-431012054). Given that, we might want to make it better so that web developers wouldn't encounter specificity issues.

Remember that there are also several requirements mentioned in this thread, as such:

[Requirement 1](https://github.com/w3c/webcomponents/issues/468#issuecomment-431172787):
> But then the author of a component can't specify !important rules for things like display without which the component may not function. This is a deal break for us.

[Requirement 2](https://github.com/w3c/webcomponents/issues/468#issuecomment-379014779):
 > I don't think it's okay to provide web page authors a mechanism to set a style user (not UA) stylesheet can't override. That would be a serious degradation for end users who need to use user (not UA) stylesheet to adjust the visual appearance of websites for accessibility purposes.

To make it better and satisfy these requirements at the same time, how about adding new *origin*, "custom elements default style declarations" to [origin and Importance](https://drafts.csswg.org/css-cascade-3/#cascading), as follows? 

1. Transition declarations [css-transitions-1]
2. Important user agent declarations
3. Important user declarations
4. **Important custom elements default style declarations**
5. Important author declarations
6. Animation declarations [css-animations-1]
7. Normal author declarations
8. **Normal custom elements default style declarations**
9. Normal user declarations
10. Normal user agent declarations

Then, I think we can satisfy requirements:

- "4. Important custom elements default style declarations" wins over "5. Important author declarations", which satisfies *Requirement 1*.
- "2. Important user agent declarations" wins over "4. Important custom elements default style declarations", which satisfies *Requirement 2*.

Blink is interested in implementing this idea, adding this new origin, "Custom elements default style declarations", and would like to see how things are going to well and get feedback from web developers.

We are aware that there was an objection to adding new origin, however, we couldn't think of any other ideas, as of now.

-- 
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-432262227

Received on Tuesday, 23 October 2018 14:11:42 UTC