[csswg-drafts] [css-cascade][css-syntax] New `!revertable` flag to mark a declaration as "can be reverted when IACVT" (#10443)

LeaVerou has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-cascade][css-syntax] New `!revertable` flag to mark a declaration as "can be reverted when IACVT" ==
This came out of #5319 but I figured I should make a new post for this for visibility, since it’s a distinct proposal.
#5319 discusses a keyword like `revert-declaration`, however I don’t think a keyword will work, since anything that is part of the value cannot be known in advance (it can be part of a variable for example). 

The problem is that UAs throw the other declarations away when they see a new one in the same scope. It's impossible to know whether the new one will ever use that keyword so they can keep the old ones around too. It works with `revert` and `revert-layer` because the other declarations are kept around *anyway* since they’re in a separate origin/layer.

However, I think a new !-flag may actually work. TBB, but some potential names could be `!revertable`, `!revocable`, `!transient`, `!layered`. Since `!`-flags need to be present at parse time and are always at the end, it doesn’t have the issues that a keyword would.
When a declaration with this flag is encountered, the UA keeps old declarations around instead of replacing them with this.

```css
/* Will not reset border-radius to 0 if --pill-radius is not set, it will just cascade normally */
border-radius: var(--pill-radius) !revertable; 
```

There can be more than one:

```css
* {
 /* Will not override animation if --effect is not set to one of these values */
 animation: if(style(--effect: grow), 1s grow) !revertable;
 animation: if(style(--effect: pulse), 4s pulse infinite) !revertable;
}
```

One open question is how would this work in the CSS OM. But we could just expose the last declaration, and authors can use Typed OM to get all of them (which allows append).

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


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

Received on Thursday, 13 June 2024 14:31:33 UTC