Re: [css-houdini-drafts] [css-properties-values-api] Should property registration be scoped? (#939)

Yup, exactly. The host element is visible to both the inner and outer scope, and it's completely reasonable for both to want to use a property on that element which they've registered. That's not getting into the forking inheritance chain, too - the host element's values inherit both into the shadow DOM *and* into the light DOM children of the element. 

Whichever way we decide "wins" and gets to define the registration for the host will cut out completely ordinary and common use-cases when there's a naming conflict. It would be a *smaller* conflict scope - only direct parent/child trees would care about naming conflicts, rather than all shadows on the entire page, but it would still introduce complexity and possible confusion. Unsure whether the trade-off is worthwhile.

A possible way to cut the knot would be to define a ::shadow-tree pseudo-element that wraps the shadow tree, and then say that the host element always takes its registration from the light DOM. If the light DOM doesn't have a registration, then the (unregistered) property can still be used on the host, and it'll inherit into ::shadow-tree where it gets interpreted by the shadow's registration and then inherited into the rest of the tree. If they *do* both have registrations, the outer page can just set the value intended for the shadow directly on ::shadow-tree instead, where it won't see the light registration at all.

This would still prevent the shadow from using the registered property on the host element itself, but that's *probably* a fairly minor restriction in practice?

(Or we could get weird and say that ::shadow-tree *is* the host element, and cascades all of its non-custom properties together with styles applied to the host element itself, but maintains custom properties separately and resolves var()s accordingly.)

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/939#issuecomment-1009207470 using your GitHub account


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

Received on Monday, 10 January 2022 18:25:08 UTC