Re: [csswg-drafts] [css-nesting] Allow custom property within nested at-rule conditions (#8753)

Right, in `@container (width > 50px)`, we're checking the width of *one element* - the container. This one element can vary while styling different elements (that is, in `@container ... { .foo { color: red; }}`, the `.foo` elements can each be querying a different container element), but for any given element, there is exactly one, well-defined, element being queried. Checking the value of a custom property on that container element is essentially identical to checkings its size.

In `@media ... { .foo {color: red;}}`, no element is referenced at all for the MQ. It checks the document itself for all its queries. So there's nothing to draw from.

And we can't change the behavior when nesting, either: in `.bar { @media ... { .foo { color: red; }}}`, we couldn't say that `@media` can reference the `.bar` element to draw values from, because... which `.bar` element? Nesting imposes *absolutely no relationship* between the `.bar` selector and the `.foo` selector; it's purely a syntax convenience letting you write shorter selectors in common situations. The `.bar` might be an ancestor, a descendant, a previous *or* following sibling, or something completely unrelated like in `.bar { .foo:not(&) {...}}`; there might be multiple `.bar` elements with the given relationship and no way to indicate which one you mean...

Finally, MQs are *defined* to be either true or false at the rule level, and this is reflected in the APIs that use them. If they start imposing truth or falsity on individual contained rules (like `@container` effectively does), instead, that's a *major* change, and fairly incompatible with how things currently work.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8753#issuecomment-1526120254 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 27 April 2023 18:11:09 UTC