Re: [csswg-drafts] [css-mixins-1] Problems with public representations of CSSOM values (#11908)

(Other minor problems)

As currently defined, [serialize a function parameter](https://drafts.csswg.org/css-mixins-1/#serialize-a-function-parameter) would return `--name <number> 1` when given `--name <number> 1` (missing `:`), instead of `--name <number> : 1`. I am not sure about the leading whitespace before `:`.

As currently defined, [serialize a CSS type](https://drafts.csswg.org/css-mixins-1/#serialize-a-css-type) would return `type("<number>")` when given `<number>`, instead of `type(<number>)`.

---

I did not think long enough before writing this:

  > I do not see why it should be represented as a syntax string [...]

I guess the intention is to allow this:

```js
const sheet = new CSSStyleSheet
sheet.insertRule('@function --custom(--parameter <number>: 1) {}')
const rule = sheet.cssRules[0]
for (const { defaultValue, name, type } of rule.getParameters()) {
  sheet.insertRule(`
    @property ${name} {
      inherits: false;
      syntax: ${type};
      initial-value: ${defaultValue};
    }
  `)
}
```

But `@property/syntax` could also be updated to accept `<syntax>` instead of (only syntax) `<string>`, right?

Assuming yes, I would suggest these representations:

| Specified in `@function`        | `.cssText`                      | `.getParameters()`, `.returnsType`
| ------------------------------- | ------------------------------- | ----------------------------------
| `type(*)`                       | omitted                         | `*`
| `type(<number>)`                | `<number>`                      | `<number>`
| `type(<number> \| <percentage>)` | `type(<number> \| <percentage>)` | `<number> \| <percentage>`

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


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

Received on Wednesday, 12 March 2025 10:45:19 UTC