w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.42k stars 648 forks source link

[cssom] "Unset by default. " #1799

Open jetvillegas opened 6 years ago

jetvillegas commented 6 years ago

https://drafts.csswg.org/cssom/#css-style-sheets

Unset by default.

We've received a feature request to allow stylesheets to be disabled in the markup. The setting for the disabled flag then defaults to the setting in the markup (unset if missing.) See this bug for more info.

FremyCompany commented 6 years ago

Seems reasonable.

tabatkins commented 6 years ago

Huh, yeah, it's not great that this is only settable from JS. I'm okay with this becoming a reflected attribute.

AmeliaBR commented 6 years ago

A hearty +1.

The current work-around is to set an invalid media attribute (I use media="only none") to effectively disable the stylesheet, but (a) that's hacky, and (b) Chrome doesn't currently support live re-loading by changing the media attribute, so you have to re-insert the <link> (or <style>) node into the DOM after mutating the attribute.

annevk commented 6 years ago

it's not great that this is only settable from JS

That's only the case in some browsers, not all support this for <link>.

This is basically https://github.com/whatwg/html/issues/1081.

upsuper commented 6 years ago

From the CSSOM's point of view, the difficulty is how this would interact with CSS style sheet set, which currently also uses the disabled flag.

It may already be a problem for StyleSheet.disabled, but this is a bigger problem if we need to synchronize the flag with the disabled attribute on the element, because the existence of CSS style sheet set feature means some of the stylesheet may be disabled when they are added even if they don't have disabled attribute (when they have title attribute), and the disabled attribute may be added / removed surprisingly when preferred CSS style sheet set is changed.

If we think CSS style sheet set isn't widely used (i.e. there are very few pages have title attribute set on <link rel="stylesheet"> and <style>), then it's probably not a big problem we need to worry about, and we can just have their disabled attribute set when that happens.

As far as I know, currently only Firefox still allows users to switch style sheet set from user interface (and even I wasn't aware of this feature before I worked on the style system and hit some test failures around that), so probably it isn't a very famous feature nowadays.

This may need working group resolution I guess. I can do the edit work if we agree to proceed with that solution.