csswg-drafts icon indicating copy to clipboard operation
csswg-drafts copied to clipboard

[css-contain-3] Should style() queries allow !important flag?

Open lilles opened this issue 2 years ago • 5 comments

According to the current draft[1], the syntax for style features are the same as for declarations which means !important is allowed as part of the feature. I don't think that would have an effect, but would it still make sense to change the syntax to not allow it?

[1] https://drafts.csswg.org/css-contain-3/#style-container

lilles avatar Jun 24 '22 10:06 lilles

We should disallow, yeah.

tabatkins avatar Jun 24 '22 17:06 tabatkins

In the case of @supports,

A trailing !important on a declaration being tested is allowed, though it won’t change the validity of the declaration.

I suspect we may want to do the same here: allow the !important syntactically, but ignore it. That way, we're consistent about the allowed syntaxes in the places that let you give a declaration for the sake of checking something rather than for declaring something. That said, if people feel strongly about disallowing it, that seems ok too.

frivoal avatar Aug 24 '22 13:08 frivoal

Disagree in the case of @supports. You're doing a syntax "is it supported" check there, and !important is arguably part of it.

fantasai avatar Aug 24 '22 16:08 fantasai

The CSS Working Group just discussed [css-contain-3] Should style() queries allow !important flag?.

The full IRC log of that discussion <astearns> topic: [css-contain-3] Should style() queries allow !important flag?
<astearns> github: https://github.com/w3c/csswg-drafts/issues/7413
<argyle> astearns: who's gonna take this one?
<argyle> florian: the syntax for style container queries, lets you specify a property declaration representing the computed value, and grammar wise, a prop dec can include !important. but that has no effect on th computed value
<argyle> florian: q is, shouuld we ban writing !Important or should be keep it even tho it has no effect?
<astearns> ack fantasai
<emilio> q+
<argyle> fantasai: i think we should disallow this becaues it represents a computed value, it has no concept of where it exists in the cascade
<florian> q+
<argyle> fantasai: i dont feel the same about @supports rules which have a siimilar sytnax, in that case, you're asking is this syntax supported and then it's fine to have !important be part of that. but if add another !something later, it'd return null
<astearns> ack emilio
<argyle> emilio: i think i disagree with fantasai because even tho it does rep the computed value, what you write is a specified value. you can query color: blue, and it's computed then compared, but
<argyle> emilio: it's a specified value right
<astearns> ack florian
<miriam> q+
<argyle> florian: i dont feel strongly, seems to me it's easier if we can copy/paste declarations from where they define and test them, to test. that might drag a !impportant along the way. if we allow it in @supports, could support it here as well. but i dont feel strongly
<astearns> agrees with the copy-paste argument
<astearns> ack miriam
<argyle> miriam: was thinking about resolving variables, custom properties in a query, but they won bring along !important. never mind, i'm fine either way
<argyle> florian: if you're using actual css var, your'e right, but if you're using server side processor that has something similar to variables, it might
<argyle> miriam: that's true
<argyle> astearns: we are out of time, is anyone else convinced byt he copy paste arg to not make a change to the sepc?
<argyle> astearns: or should we continue discussion int he issue?
<argyle> astearns: not going to get reslution to this, we will continue in the issue. bring it back to the agenda onde we have clarity
<masonf> Thank you Adam!

css-meeting-bot avatar Aug 24 '22 17:08 css-meeting-bot

I think it is very likely that authors will copy-paste values (or have them set by build-time variables) that will contain !important and be surprised or not notice that their style() query became invalid. So I think we should continue to allow them.

astearns avatar Aug 24 '22 17:08 astearns

FWIW, I'm fine with closing this as no change. I have changed our implementation to allow !important and adjusted the WPTs accordingly to match the current spec.

lilles avatar Sep 09 '22 13:09 lilles

Sorry for that noise. I was clicking badly. Meanwhile, I agree with the general (though incomplete) consensus here that !important should be allowed and ignored. Proposing we close this wontfix.

mirisuzanne avatar Oct 28 '22 20:10 mirisuzanne

I agree that we should just close this. I have updated our impl to match the current spec and allow !important in style() query values.

lilles avatar Oct 31 '22 12:10 lilles

Proposed resolution: no change

lilles avatar Dec 16 '22 10:12 lilles

@tabatkins @fantasai would you be OK with a resolution of no change here?

astearns avatar Dec 20 '22 23:12 astearns

Sorry for that noise. I was clicking badly. Meanwhile, I agree with the general (though incomplete) consensus here that !important should be allowed and ignored. Proposing we close this wontfix.

Another vote for this.

LeaVerou avatar Dec 21 '22 12:12 LeaVerou

I have no strong opinion, so I'm fine with an async resolution in either direction.

tabatkins avatar Dec 21 '22 18:12 tabatkins

Ditto @tabatkins. I personally think it doesn't belong as part of style() syntax, but if there's a convenience to allowing it I don't see it as problematic.

fantasai avatar Dec 22 '22 05:12 fantasai

Since this has consensus here in the issue we likely do not need to spend meeting time on it.

The CSSWG will automatically accept this resolution one week from now if no objections are raised here. Anyone can add an emoji to this comment to express support. If you do not support this resolution, please add a new comment.

Proposed Resolution: No Change

astearns avatar Dec 22 '22 16:12 astearns

RESOLVED: No change

astearns avatar Jan 03 '23 05:01 astearns