[csswg-drafts] [css-values?] Accept <number> where <integer> is expected (#6786)

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

== [css-values?] Accept <number> where <integer> is expected ==
Currently there are a lot of places where authors end up having a `<number>` instead of an `<integer>` without realizing, then are puzzled why their code doesn't work.

For example:

```css
--columns: 12;
grid-column-end: span calc(var(--columns) - 8); /* works */
grid-column-end: span calc(var(--columns) / 3); /* fails, IACVT */
```

Same issues with `counter-reset`, `z-index` and the list goes on. 

In fact, clever authors have even come up with [_terrible hacks_](https://twitter.com/anatudor/status/1399849494628425734) for working around this by assigning the number to a registered `<integer>` property and taking advantage of that implicit conversion. Sure, once `floor()` and friends are supported this would be much simpler, but IMO authors should not even have to think about this. A `5` is a `5`, whether it was generated as `4 + 1` or as `15 / 3`. Since `<number>` cannot be disambiguated from `<integer>`, I doubt we have any syntax that depends on them being incompatible. 

**Proposal:** accept `<number>` anywhere an `<integer>` is accepted, after flooring (or rounding, no strong opinion).

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


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

Received on Monday, 1 November 2021 17:34:54 UTC