- From: Sam Atkins via GitHub <noreply@w3.org>
- Date: Mon, 14 Jul 2025 10:10:57 +0000
- To: public-css-archive@w3.org
AtkinsSJ has just created a new issue for https://github.com/w3c/csswg-drafts: == [css-values-5] Clarify how `<attr-unit>` should be parsed == The spec for this [says](https://drafts.csswg.org/css-values-5/#ref-for-typedef-attr-type%E2%91%A0): > If given as an [`<attr-unit>`](https://drafts.csswg.org/css-values-5/#typedef-attr-unit) value, the value is first parsed as if `type(<number>)` was specified, then the resulting numeric value is turned into a dimension with the corresponding unit, or a percentage if % was given. Values that fail to parse as a `<number>` trigger fallback. `<number>` can mean a literal number, but it can also be a math function, or various other functions that produce `<number>`. Chromium added a [crash test](http://wpt.live/css/css-values/crashtests/chrome-405422528-crash.html) which checks that a non-literal appearing doesn't break the browser: ```html <!DOCTYPE html> <link rel="help" href="[https://crbug.com/405422528](view-source:https://crbug.com/405422528)"> <div data-crash="sibling-index()" style="width: attr(data-crash px)"></div> <div data-crash="sign(1em - 1px)" style="width: attr(data-crash px)"></div> ``` But their [fix](https://github.com/chromium/chromium/blob/1b76fc9f583b8fa1be1fc2dc13d61e205bc6f977/third_party/blink/renderer/core/css/css_attr_type.cc#L85-L95) assumes that only `<number>` literals are allowed. The spec is ambiguous here. Only allowing literals is one interpretation (and certainly the easiest to implement!) but the other interpretation (which I read the spec as meaning) is that this: ```html <div data-crash="sign(1em - 1px)" style="width: attr(data-crash px)"></div> ``` ...should produce a `width` value equivalent to `calc(sign(1em - 1px) * 1px)`. cc: @lilles Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12479 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 14 July 2025 10:10:58 UTC