Re: [csswg-drafts] [css-anchor-positioning-1] [scroll-animations-1] [css-view-transitions-1] Scoping names on elements based on tree scope (#10304)

@fantasai did some digging around on this and landed on https://drafts.csswg.org/css-scoping-1/#shadow-names. This is the closest thing in CSS specs which is trying to define a generic concept of how global names should be handled. This was discussed on https://github.com/w3c/csswg-drafts/issues/1995.

There's 2 relevant concepts:

- Tree scoped name: Each time a name is defined it is assumed to be global within its tree scope. The root element hosting the stylesheet is implicitly part of the namespacing for these names.
- Tree scoped reference: When a name is used by a CSS property (like `animation-name`), the root element hosting the stylesheet (which establishes it's tree scope) is again captured.

When de-referencing a tree scoped reference, we start looking in the tree scope which matches the reference and keep going higher in the tree scope hierarchy until a match is found. This essentially means that names defined in a tree scope are visible to the descendants by default (if they are not overridden) but names defined in an inner tree scope are not visible to outer tree scope. This has been highlighted as an issue for anchor positioning, see https://github.com/w3c/csswg-drafts/issues/9408.

But there's 2 issues with the above:
- This means names in a scope are visible throughout the subtree by default which goes against @annevk's comment [here](https://github.com/w3c/csswg-drafts/issues/10145#issuecomment-2175556049) that exposing names should be an opt-in.
   
   There's also a comment about names in inner scope going only 1 level up but that's a separate conversation since names are not exposed up in the hierarchy.

- The implementation doesn't align with the spec. At least for `@keyframe` and `@property` the names defined in an outer tree scope *can't* be referenced by the inner tree scope in Chrome, Firefox and Safari. And this is actually good if we do want an opt-in for names to be visible across shadow DOM boundaries.

So adding this to the agenda to revisit the spec.

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


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

Received on Tuesday, 25 June 2024 19:28:24 UTC