Re: [csswg-drafts] [css-cascade-5] Allow authors to explicitly place unlayered styles in the cascade layer order (#6323)

> I don't think we can make the foo.!top an invalid layer, unless the proposal is to make top-level layers bubble up through regular ones and be always at the top even when they're nested?

I think you misunderstood what I meant. I was saying that we'd make `foo.!top` an invalid layer name to specify; you'd have to write a sublayer after it, like `foo.!top.bar`; similarly, you couldn't write `@layer foo { @layer !top {...}}`, you'd have to write `@layer foo { @layer !top.foo {...}}`. That way, no styles would ever be inserted *directly* into a top layer; they'd always be nested into a named layer.

> We have to allow these in nested contexts, so either way !top.!top.!top is a valid option.

Not quite; those characters form valid syntax in both, but mean different things and act differently. You could have top layers named "top" in Option 2, sure, but they'd work like any other named layer, and thus could be targeted and explicitly sorted by preceding code pre-declaring the layer order. A quick `@layer !top !my-stuff;` ensures that your stuff wins in the layer sorting.

But in Option 3, nested !tops *always* appear at the end of the order on a given layer. No matter what you do, something in `!top` comes after `foo`, and even after `!top.foo` (because the styles are unnested within the `!top` layer, and thus go at the end); to put your own thing after, you have to exceed their number of `!top`s and do `!top.!top`.

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


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

Received on Wednesday, 23 October 2024 20:13:33 UTC