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

CSS Scoping for at-rules has since been added to [CSS Scoping](https://drafts.csswg.org/css-scoping/#shadow-names), it would be nice to add these rules to the rest of Houdini things. 

The worklets should all be easy enough as each shadow dom could just have a "copy" of each worklet which while not neccessarily being a separate Worklet, calling `registerSomeClass("some-name"` would register it to the associated shadow tree.

CSS properties seems particularly tricky though, cause unlike other at-rules and named worklet things, it's not the value that can be inherited into the shadow tree but the property itself. 

Also one would probably want to be able to expose specific custom properties to the light DOM for certain customization, just from a very cursory sampling of components listed on webcomponents.org, many components support styling through CSS custom property names, and *often* these names are generic. Maybe we could export CSS properties (similar to how we do with elements and `::part`) and reference them in stylesheets by a prefixed custom property name or something e.g.:

```css
/* Style the custom element with some exposed properties */
custom-element {
  --color: red; /* This property is the usual light DOM property */
  exposed--color: red; /* This is a property exposed from the Shadow DOM */
  exposed--theme: --disco-lights; /* Ditto */
}
```

```css
/* Inside the shadow root */
@property --color {
  /* Declare property as exposed so can be set by consumers of component */
  exposed: true;
  syntax: "<color>";
  initial-value: black;
}

@property --theme {
  exposed: true;
  syntax: "--plain | --disco-lights | --moody-evening-lake | --christmas";
  initial-value: --plain;
}

@property --private-use {
  exposed: false; /* Not exposed, the default, so exposed--private-use externally won't work */
  syntax: "<angle>";
  initial-value: 0deg;
}
```

-- 
GitHub Notification of comment by Jamesernator
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/939#issuecomment-915165074 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 11:48:28 UTC