Re: [csswg-drafts] [css-variables-2] Substitution takes place at the level of CSS component values (#11316)

The example in my initial comment is not good because if substitution takes place at the level of CSS tokens, there is just an unclosed `calc(` at substitution time.

This one is better and demonstrates a difference between Chrome and Firefox:

  > ```html
  > <style>
  > #element {
  >   margin: calc(1px / var(--custom)) 1px;
  >   --custom: ( 2;
  > }
  > </style>
  > <div id="element"></div>
  > <script>
  >   getComputedStyle(element).margin // 0px in Chrome, 0.5px 1px in Firefox
  > </script>
  > ```

Chrome operates substitution on a list of tokens and sees `calc(1px / (2) 1px`, which is invalid, whereas Firefox operates it on a list of component values and sees `calc(1px / (2)) 1px`, which resolves to `0.5px 1px`.

CSS Syntax requires consuming a declaration value as a list of component values but it could be "flattened" back to a list of tokens before applying substitutions.

Did I understand correctly? Can I close this issue and assume this is an issue in Firefox?

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


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

Received on Wednesday, 19 March 2025 14:32:58 UTC