[csswg-drafts] [css-syntax-3] Define serialization of `<declaration>` and `<any-value>` (#8735)

cdoublev has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-syntax-3] Define serialization of `<declaration>` and `<any-value>` ==
This is a follow-up of an aside I made in #8728. I do not know if defining the serialization of `<declaration>` and `<any-value>` (which only appear in rule's preludes) is worth someone's time but there is a [`@container` related WPT case](https://wpt.fyi/results/css/css-contain/container-queries/at-container-style-serialization.html?label=master&label=experimental&aligned&q=css%2Fcss-contain%2Fcontainer-queries%2Fat-container-style-serialization.html) that is currently failing in some browsers.

Chrome/FF serialize `<declaration>` exactly as specified by the author in `@supports`, but the serialization in `@container` is inconsistent in Chrome and the the above mentioned [WPT case](https://github.com/web-platform-tests/wpt/blob/5acfa513ebd07b44adc8be2fc2c491e1b90236da/css/css-contain/container-queries/at-container-style-serialization.html), which seems to be identical to the serialization of `<any-value>` in Chrome (v112 below):

```css
              @supports (opacity: 1.0 /**/) {}
// Chrome/FF: @supports (opacity: 1.0 /**/) {}

           @container style(--custom: 1.0 /**/) {}
// Chrome: @container style(--custom: 1 ) {}
//     FF: @container style(--custom: 1.0 /**/) {}

           @container (<any-value> 1.0 /**/) {}
// Chrome: @container (<any-value> 1 ) {}
//     FF: @container (<any-value> 1.0 /**/) {}

           @media (<any-value> 1.0 /**/) {}
// Chrome: @media (<any-value> 1 ) {}
//     FF: @media (<any-value> 1.0 /**//) {}
```

I do not see the benefits of serializing exactly as specified by the author, or why it would be required, and adds an extra complexity in tokenization. 

A comment appearing before the ending token of a simple block (like in the above examples) can only be part of the representation of the ending token (`)`), because tokenization requires to repeatedly consume a token by consuming any comments before consuming following code point(s).

This makes it difficult to serialize `(name: value /* inside */)` exactly as specified because `<declaration>` can only represents `name: value `, according to tokenization, without implementing some contrived logic in *consume a simple block* and *consume a function* to slice/append the representation of the comment in/to the appropriate component.

On the other hand, serializing the component values would to replace the appropriate parts of [*serialize a CSS value*](https://drafts.csswg.org/cssom-1/#serialize-a-css-value) that remove whitespaces and join components with a whitespace, by joining them with no space.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8735 using your GitHub account


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

Received on Wednesday, 19 April 2023 12:00:14 UTC