Re: [csswg-drafts] [css-properties-values-api] "Property registration cannot be scoped" differs from all implementations in a consistent way (#10541)

> no idea how we'd expose these distinctions via the OM.

I think the clean way to expose this would be `shadowRoot.getComputedStyle(element)`

> If the property was not exported to the top frame though, it is clearly unintended that they would conflict, so it is nice if they can be effectively isolated.

I agree that it's a nicer model, I'm not convinced yet that it's worth the subtle complexity it introduces.

> 
> > Its somewhat easier to grasp a model where custom properties are like ordinary properties - an element can only have one `--background-color` in the same way that it has only one `background-color`, and authors should be careful when they use custom properties in `:host` and `::part` just like they need to be careful with ordinary properties in these interface points.
> 
> Even if a developer controls both scopes and is really careful, which scope's type / default value would you use on these elements?

Like Tab suggested, the inner wins for `:host`. I think the outer needs to win for `:part`.

> 
> The other question which is still a bit unclear to me, is would we be able to inherit a value on the outer scope set on the host in the parts if these conflict?

No. You'd have to do this manually (use different names).

> 
> TLDR, not saying that we have to go with this more complex option, but I think it could have some nice flexibility to manage the conflict. I think we should consider some real use cases or find some means to work out whether it's worth the complexity of custom properties being tree scoped.

SGTM!

> 
> Note that making it a tuple on registered scope could be internally handled by some hash of the scope on the name which is internally removed before exposing the property name to the developer which could reduce the implementation complexity.

Not worried about internals at all, more about introducing subtle edge cases to the mental model where custom properties are scoped differently from regular properties.

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


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

Received on Friday, 27 September 2024 04:03:08 UTC