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

> > Since :host is defined in the inner scope, it should share the inner scope definitions.
> 
> But rules from `:host` inherit through the inner _and outer_ scopes, right?

Let's look at an example:

```css
/* in outer scope */
@property --some-color {
  syntax: "<color>";
  inherits: false;
  initial-value: red;
}

body {
  outline-color: var(--some-color);
}

my-calender { 
  background-color: var(--some-color); 
}

/* in inner-shadow style of my-element */
@property --some-color {
  syntax: "<color>";
  inherits: false;
  initial-value: black;
}

:host { 
  color: var(--some-color);
}

/* a table inside the shadow tree */
table {
  border-color: var(--some-color);
}
```
I'd probably expect the background to be red and the color + the internal table's border color to be black.
What @flackr suggested in https://github.com/w3c/csswg-drafts/issues/10541#issuecomment-2378165299 is what would  achieve this, but it complicates the model in terms of what a "custom property" is.

It's clear that the table's `border-color` should be black and the body outline color should be red.
However, it's unclear what the `my-calender` color should be. If we say properties are private, then the host should also not inherit them. That's the "special" thing about `:host` - it's indeed in the light DOM, but it's part of the custom element.
However, this expectation is not obvious and in some cases you might want something different...

Perhaps this can be another `@property` descriptor that defines whether this property can pierce shadow roots, as long as the <syntax> is the same, and if so it would just use the `initial-value` as a new default in case it's not delegated?

something like `scope: private | inherit` that makes this explicit, with a `private` default and fall back to private when there is a syntax mismatch.

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


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

Received on Thursday, 31 October 2024 11:32:06 UTC