W3C home > Mailing lists > Public > public-css-archive@w3.org > July 2021

[csswg-drafts] [css-cascade-5] Any needs to avoid other layers overriding name-defining @-rules? (#6461)

From: Xiaocheng Hu via GitHub <sysbot+gh@w3.org>
Date: Mon, 19 Jul 2021 19:02:52 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-947939624-1626721371-sysbot+gh@w3.org>
xiaochengh has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-cascade-5] Any needs to avoid other layers overriding name-defining @-rules? ==
The current spec already allows a layer to make a declaration `!important`, so that other layers cannot override it. For example:

```
@layer base { 
  @keyframes foo { ... }
  #target {animation-name: foo !important; }
}

@layer override {
  @keyframes bar { ... }
  #target {animation-name: bar;}
}

/* #target ends up animated with foo */
```

However, override layers can still override the animation by overriding the at-rules (as discussed in #6404):

```
@layer base { 
  @keyframes foo { ... }
  #target {animation-name: foo !important; }
}

@layer override {
  @keyframes foo { ... }
}

/* #target ends up animated with overridden animation */
```

In this way, even though the base layer doesn't want to be overridden, the override layer still has a way to get around it. This is probably against the intention of the author of the base layer, and against why we have the `!important` keyword.

---

I'd like to discuss:

1. Do we want to introduce a mechanism so that override layers cannot override at-rules defined by base layers?
2. If yes, how?
    - Allow `!important` keyword on at-rules?
    - Introduce something like "layer-scoped name/reference" (similar to [tree-scoped name/reference](https://drafts.csswg.org/css-scoping/#shadow-names)), so that declarations in the base layer cannot reference at-rules defined by the override layer?
    - Other thoughts?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6461 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 19 July 2021 19:02:54 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:39 UTC