W3C home > Mailing lists > Public > public-css-archive@w3.org > August 2016

[csswg-drafts] [css-values] Computed value of a negative calc unit in that doesn't allow negative lengths.

From: Emilio Cobos Álvarez via GitHub <sysbot+gh@w3.org>
Date: Tue, 30 Aug 2016 21:58:57 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-174136651-1472594335-sysbot+gh@w3.org>
emilio has just created a new issue for 
https://github.com/w3c/csswg-drafts:

== [css-values] Computed value of a negative calc unit in that doesn't
 allow negative lengths. ==
In the [CSS values spec, section 8.1.4. Range 
Checking](https://drafts.csswg.org/css-values/#calc-range):

> However, the **used value** resulting from an expression must be 
clamped to the range allowed in the target context.

Note that the used value is expected to be clamped, but not the 
computed value. Both Blink and Firefox (at least, probably other 
engines too) clamp the value at computed value time, as can be seen 
running the following test, where all the properties that don't accept
 negative lengths (like `font-size`, `padding-xxx`, etc.) report a 
computed value of `0px` instead of the expected `-1px`.

```html
<!doctype html>
<script>
window.onload = function() {
  let style = window.getComputedStyle(document.body);
  for (prop of style) {
    if (prop in document.body.style) {
      document.body.style[prop] = 'calc(-1px)';
      console.log(prop, "reported: ", 
getComputedStyle(document.body)[prop]);
    }
  }
}
</script>
```

Please view or discuss this issue at 
https://github.com/w3c/csswg-drafts/issues/434 using your GitHub 
account
Received on Tuesday, 30 August 2016 21:59:05 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 19 October 2021 01:30:22 UTC