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

Argh, yeah, @property is a *problem* for scoping. (Sorry, I'm gonna repeat some of your reasoning in laying out my thoughts.)

So, there's two very distinct uses of custom properties in components: allowing the outside page to pass data into the component, and using custom properties purely internally for all the fun uses you can put custom properties to.

The first is fundamentally incompatible with scoping. Properties intended for this usage *have* to be registered globally, so they have a consistent registration across all the scopes the property is passing over. (In a more full-featured programming language we could be better about lexical scoping and explicitly exposing properties for use, relying on object identity, but CSS's design makes this very difficult.) This'll mean that components have to be mindful about global name collisions and possibly defensively uniquify their names, but I just don't see a way around that.

The second is theoretically compatible with scoping, but has some additional implications. If you have a private registration, then a property inheriting in from the outside *by definition* can't be using that registration, and thus must be blocked; thus we basically have to block inheritance.

But there's a further problem - the host element is in two scopes at once, and thus can see two conflicting registrations of the same property name. I don't see how to reconcile this; even if we somehow keep both around with an internal uniquifying of the name, it's not clear how to expose that to script when they ask for the value of the property.

Unfortunately, the only way I can see to get around this is to uniquify the names here, too, so there's minimal chance of name overlap. We just don't have the programming primitives necessary to achieve actual usable uniqueness.

And so, if we have to uniquify the names anyway, I don't see a strong need to try and address this directly. Some guidance in a spec is probably warranted, but as far as I can tell anything we do to address this will just be codifying some form of uniquifying without any real reduction in typing for the author.

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


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

Received on Wednesday, 8 September 2021 16:36:49 UTC