logoalt Hacker News

chrismorgantoday at 11:41 AM1 replyview on HN

> cases where you don't need to set a value

I don’t know what you mean.

> when your condition requires a more complex selector (e.g., a parent/root context)

I don’t see the problem. :where() takes a <complex-selector-list>.


Replies

tenphitoday at 12:29 PM

For example, I want to set (override the inherited one) a custom property by default, but not when some condition is met. Yes, it might be solved with `inherit`, but in other cases `initial` should be used. I prefer not to define anything unless necessary, so the default (from the cascade) can still be used.

You are probably right about `:where`, but using it with complex selectors might noticeably affect the performance, as it does with `:has`. Didn't run any test for `:where` specifically, though. Also, we apply lots of styles to the same elements, most of which are overridden.

Another issue is using a different set of longhand/shorthand properties for different states that won't be correctly overridden in this approach.

So it might work pretty well in most of the cases, especially simple ones. But it's definitely not better than mutually exclusive selectors.

show 1 reply