Re: [csswg-drafts] [selectors] Functional pseudo-class like :matches() with 0 specificity

Having something like that `:is()` instead of the nested `:not()` hack would be so much better of course.

Though, I'm still thinking about (maybe alongside this `:is()`) having some way of creating your own cascade level, which you could then place above or below the default author one. This would allow either to import any external library on a level below, or write your styles on a level below, or even write code in multiple levels, like according to @csswizardry's ITCSS. 

I understand that that goes beyond the scope of this exact issue, but in my opinion this would cover some of the cases much better and with much less code from the authors (and I think it should be also really easily implementable, the main problem would be in coming up with syntax and handling all the nuances). Below I'd briefly write what I managed to come up with, if that sounds good and there is interest for something like that or at least for discussion, I could create a new issue for it maybe (for `[css-cascade]` probably?).

1. By default all the author CSS goes to the default “Normal author” level (or “[origin](”, but I like the term “layer” for this thing more).

2. Now, it is possible to create a new “layer”. There are now two possibilities: either this layer would be nameless, or with a set name:

- Nameless layers: `@layer {…}` — by default everything that would go into those nameless layers would be put into one layer/origin that is above the one they were declared at. There should be also a way to put those not above, but below the current level, either with some keyword or stuff like `@layer (position: below) {…}`.
- Named layers: `@layer foo {…}` — whenever you declare a new layer this way, it would be placed above the previous declared one (or below if used with a keyword). Then, all the next `@layer`s with the same name would be merged into this place, so the first occurrence matters.

3. Layers can be nested one into each other, and there should be a way to handle things similar to how we can now handle stacking context & z-index (we should be able both to put the layer somewhere in the global context, or only manage it inside the current layer).

Basically, that's it. There are a lot of nuances and ways to implement some of this stuff, but: the main idea is to have a simple way of separating big chunks of code into independent layers similar to how the cascade of origins works now, basically allowing authors to create multiple author origins (or — split the current author's origin into multiple layers, as all those styles should still be at its place in the cascade).

And, yes, the idea is still raw, and if there is interest we can discuss it in a new issue I guess? And, anyway, I think there regardless should be a way to handle the specificity of selectors like with `is()`, and I like the proposals for it above.

GitHub Notification of comment by kizu
Please view or discuss this issue at using your GitHub account

Received on Friday, 15 September 2017 20:24:22 UTC