Open atanassov opened 4 years ago
Given that this proposal seems to be custom-element-specific, probably [css-shadow-parts-1] would be a better place for it than [css-pseudo-4]?
it was surprising that this topic hasn't been discussed with the csswg yet
Procedurally, is it incumbent on us as CSSWG members to notice specifications developed in WICG that impact CSS, and to then bring them up for discussion here to provide feedback in that venue?
No, it's supposed to be part of our process to rope in appropriate experts, and in this case would absolutely be a "file an issue in CSSWG" sort of thing. Failing on our part, sorry about that; I didn't realize we were at the ItS stage yet.
How does this relate to https://github.com/w3c/csswg-drafts/issues/3431?
The CSS Working Group just discussed Custom state pseudo class proposal
.
(subscribing myself to this issue)
CSSWG minutes are here: https://lists.w3.org/Archives/Public/www-style/2020Mar/0009.html An important comment was to make sure this feature can handle enums, not just boolean states.
Web Components f2f minutes here: https://github.com/WICG/construct-stylesheets/issues/45#issuecomment-602756608
Overall there's consensus on implementing document.adoptedStyleSheets
as an ObservableArray
.
There also appears to be consensus on moving document.styleSheets
to a (readonly) ObservableArray
subclass, so it'll sprout the same array methods.
The contentious question that couldn't be resolved on the call, and which is being left for us to decide, is whether direct assignment of an array is allowed; that is, whether document.aSS = [ss1, ss2];
works or throws.
Points in favor:
el.classList
allows it; Typed OM array-likes intend to allow it; various CSSOM APIs (CSSMediaRule.media
and CSSStyleRule.style
effectively allow it, via their [PutForwards]
extended attributes that allow setting to a string to replace the associated lists)..splice()
, or emptying the array and then .push()
ing). Complex restrictions seem bad without strong reasons for them, as it means authors have to learn a more complex API boundary and can't rely on knowledge from elsewhere.Points against:
.push()
, it wouldn't clobber anything.document.aSS
will have equal contents to the array you set, but not equal identity (it'll return an ObservableArray object, not the iterable the author assigned). This is distinct from how userland array-valued properties tend to work, and might be weird.I'm at this point strongly on the "assignment should be allowed" camp. In particular, the first point against was most vociferously argued, and I think it's absolutely something we should reject. The footgun is not "clobbering the superclass's styles", it's subclassing at all. It is exactly as dangerous to naively clobber the superclass's styles as it is to naively append to the superclass's (unknown) styles; both are equally likely to screw up your component with parts not getting the styles they expected.
In addition, this problem is common to every single aspect of the superclass, not just styles. Literally anything the subclass does might, if it's not aware of what the superclass is doing, screw up what the superclass is doing. Adding a special-case restriction to try and make subclasses less likely to screw up this specific case won't materially improve the situation. Even if it weren't the case that I think .push()
ing is just as dangerous (so there's no way to reduce the risk anyway), increasing the complexity of the overall API surface for an insignificant improvement in safety is generally a bad tradeoff, I believe. We've made the judgement that similar sorts of tradeoffs aren't worthwhile elsewhere in CSS.
So anyway, Agenda+ to get a final decision on this. I secured a promise from Apple to ensure a relevant person attends the CSSWG call, so hopefully this can be bumped for this week's agenda?
Constructible Stylesheets seems like a separate issue and separate spec from Custom State Pseudo Class, perhaps it merits a separate issue?
Whoops, yeah, I posted this to the wrong place. I'll move it appropriately.
An important comment was to make sure this feature can handle enums, not just boolean states.
I found a bunch of discussion including what looks like a concrete proposal here: https://github.com/WICG/custom-state-pseudo-class/issues/4#issuecomment-632556585 What does everyone think?
The CSS Working Group just discussed [selectors] Custom state pseudo class proposal
, and agreed to the following:
RESOLVED: merge a limited version of https://github.com/WICG/webcomponents/blob/gh-pages/proposals/custom-states-and-state-pseudo-class.md into Selectors 5
I started a PR: https://github.com/w3c/csswg-drafts/pull/8213
Agenda+ as per @josepharhar's request, re. the discussion about :state(foo)
and :--foo
Some of that discussion is in https://github.com/whatwg/html/pull/8467, ftr.
context: I don't have an opinion about :state(foo)
vs :--foo
, but @rniwa thought that we should be doing :state
here: https://github.com/whatwg/html/pull/8467#issuecomment-1648866722
There was also a previous discussion/resolution in the CSSWG here: https://lists.w3.org/Archives/Public/www-style/2020May/0017.html
:--foo
is also proposed for custom selectors, e.g. https://drafts.csswg.org/css-extensions/#custom-selectors has this example:@custom-selector :--heading {
expansion: h1, h2, h3, h4, h5, h6;
}
The CSS Working Group just discussed [selectors] Custom state pseudo class proposal
, and agreed to the following:
RESOLVED: Change from -- to state
The :--foo
syntax has been shipping in stable chrome for some time now, with a usecounter at 0.03%: https://chromestatus.com/metrics/feature/timeline/popularity/3796
I'm going to send an intent to deprecate for the old syntax with a plan to replace it with the new syntax, but I am concerned that my proposal to change the syntax may be rejected. I will post updates here.
@rniwa @annevk
The HTML side of this has merged. But it also needs to be added to Selectors for parsing purposes. Semantics can be left to the host.
Based on recent TAG review of the proposed Custom State Pseudo Class feature it was surprising that this topic hasn't been discussed with the csswg yet.
Given Chrome has an intent to ship this feature it will be helpful for us to at least discuss it.