Re: [css-houdini-drafts] [css-properties-values-api] Generally ignore syntax in APIs. (#912)

@tabatkins We will probably need to think outside the box we've created for ourselves to proceed, so here goes:

We could make `@property` a thing which takes effect immediately during parsing:

```
@property --x {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

--x: 10px; /* Actually parsed as <length> parse-time */
```

Let's invent a `[[declaredPropertySet]]` slot on the associated Document. This slot is like `[[registeredPropertySet]]`, except `@property` properties go in `[[declaredPropertySet]]` and `CSS.registerProperty` properties go in `[[registeredPropertySet]]`.

 1. We _may_ query `[[registeredPropertySet]]` during `setProperty`, specified value reification in Typed OM (and so forth), but _not_ the `[[declaredPropertySet]]` slot. The `[[declaredPropertySet]]` slot may be queried (if necessary) by computed-value APIs *ONLY*.
    - This means we _can_ continue to reify specified values according to what's registered with `CSS.registerProperty`. I don't think we _actually should_, as we'd be misrepresenting the truth in the CSS declaration block.
 2. `@property` rules take effect immediately in the parser, which means that the parser can actually parse subsequent declarations according to the syntax right away.
 3. Since we parse real values right away, they exist natively in the parsed representation, and hence specified values reify with proper types automatically.
 4. `@supports` can now detect whether a given `@property` rule worked. (Yay, fallback).
 5. We can reject declarations parse-time.
 6. Properties declared with `@property` still substitute as their computed values. This means that previously parsed custom properties must be reinterpreted computed-value time, if a property is re-registered:

```
@property --x {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

--x: 10px; /* <length> */

@property --x {
  syntax: "<color>";
  inherits: false;
  initial-value: red;
}

/* --x is still a <length>, but is now invalid at computed-value time */
```

 7. If a property is _also_ registered with `CSS.registerProperty`, that registration wins, and any value parsed as a result of `@property` rules are reinterpreted computed-value time.

Open questions:

 8. How to determine whether a property inherits if multiple `@property` rules exist and disagree.
 9. Which types do we accept (via `.set()` etc) in TypedOM for `@property`-registered properties? We can't look at the at the `[[declaredPropertySet]]` slot. We could accept anything (see previous comment). Or we could invent something new, like associating the `[[declaredPropertySet]]` with the `StylePropertyMap`/'CSS declaration block' instead of the Document. That way, the information we need is always locally available whenever something is parsed.

-- 
GitHub Notification of comment by andruud
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/pull/912#issuecomment-511741949 using your GitHub account

Received on Tuesday, 16 July 2019 09:33:03 UTC