Skip to content

[css-contain-3] Move style queries of standard properties to level 4 #7185

@anttijk

Description

@anttijk

Style queries for standard (non-custom) properties are currently severely underspecified and have many open questions in terms of behavior, implementability and usefulness.

Some examples:

How does style(width: calc(…)) behave?

Will authors understand why this (or any particular value syntax) is available with style() but not with the usual size query syntax () especially when feature and property names are the same?

As far as I know there is no definition of “equality” in general between the computed style and some arbitrary author property value. Engines have some internal notion of equality between two computed styles but that doesn’t seem sufficient here. This would need to be fully specified in all cases.

How about shorthand properties?

What happens with style(color:inherit) or say style(color:revert-layer)? Are we supposed to run full style resolution pipeline in middle of selector matching to determine the value being queried? Based on #7080 it sounds like there are plans to limit some but not all global values. How do authors know what is allowed?

Possible spec/implementation shortcuts for above (“just serialize and use string equality”) have major performance concerns.

Is this feature useful as specified? Exact equality is very limiting. Many interesting properties are numbers or multidimensional objects like colors. Size queries support ranges for a reason.

How does this interact with animations? Accelerated ones where style is not resolved for every frame?

There is a huge testing matrix for this with 600+ properties (and infinite amount of complex values).

It seems to me that this feature as specified adds a massive amount of complexity for very limited utility. A serious implementation effort would surely find way more questions.

Container queries without style queries (or style queries limited to custom properties/variables) offers a nice set of functionality. It seems unwise to delay those features in pursuit of this.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Needs Edits

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions