Re: [csswg-drafts] [css-anchor-1] Tree-scoped references don't play nicely with transition styles (#8180)

I have an alternative idea which is less groundbreaking and should fix this issue, but not the other (#8181).

Currently, [tree-scoped reference](https://drafts.csswg.org/css-scoping/#css-tree-scoped-reference) is defined at a per-property level, namely, only a property's whole value is tree-scoped:

> Properties or descriptors that reference a "global" name, such as the [font-family](https://drafts.csswg.org/css-fonts-4/#propdef-font-family) or [animation-name](https://drafts.csswg.org/css-animations-1/#propdef-animation-name) properties, must define their value as a tree-scoped reference.

We just need to change it to per CSS value.

Then if two CSS values are combined into a `calc` expression, their tree-scoped references must remain as-is in the combined expression tree. This allows preserving the tree scope references in the result of an addition and interpolation. It also allows combing two values from different tree scopes.

Then it should already work for transition styles, because it only [applies an interpolation](https://www.w3.org/TR/css-transitions-1/#application) between two computed styles to the element, and the two computed styles should already have tree-scoped references.

Same for CSS animations: CSS keyframes can be tree-scoped by the hosting stylesheets, and then the animation style is just a combination of the keyframes.

I'm not sure how to make it work with Web Animation API though, because JS is not naturally tree-scoped. But I think this is a more general issue that's not limited to anchor positioning (see eg [test case for counter styles](https://jsfiddle.net/w8bhxt7u/)).




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


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

Received on Thursday, 12 January 2023 22:20:19 UTC