Re: [csswg-drafts] Proposal: Custom CSS Functions & Mixins (#9350)

@LeaVerou 

> But like I said, I suspect it would not be feasible. That said, we should definitely explore feasibility, rather than ruling it out upfront.

At first glance, it seems like there's many ways this could be done:

* Have some very restrictive rules for what selectors would work, like only `element`, `.class` or `#id` selectors
* Match selectors *exactly*, so `@same-as .a>.b` would not pull in `.b`
* Analyse selectors and find supersets, so `@same-as .a>.b` would pull in `.b` because all `.a > .b` are, inherently, `.b`

There's obvious downsides to all of these, but I'm not seeing why this is necessarily not feasible. Even the third option, which probably adds the most work for implementations, still seems quite doable compared to many other modern CSS features that are being implemented. But as always: I don't build browsers, so I wouldn't know for sure.

From a purely wishful thinking CSS author perspective, I really like of defining styles on an element like `button`, then pulling those rules directly into `a.button`, because it benefits from the well known semantics of the `<button>` element; I think this would make code easier to read, while still leaving plenty of rooms for frameworks to use more esoteric nomenclatures like prefixed classes, etc.

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


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

Received on Wednesday, 28 February 2024 08:13:17 UTC