MoOx / postcss-cssnext

`postcss-cssnext` has been deprecated in favor of `postcss-preset-env`.
https://moox.io/blog/deprecating-cssnext/
MIT License
5.3k stars 188 forks source link

returns NaN when dividing var() in calc() in preserve mode #427

Closed rokoroku closed 6 years ago

rokoroku commented 6 years ago

with postcss-cssnext options

features: {
  customProperties: {
    preserve: true
  }
}

below css

:root {
    --iconSize: 14px;
    --lineHeight: calc(var(--iconSize) / 8);
}

results

:root {
    --iconSize: 14px;
    --lineHeight: NaN;
}

It's weird, because orginal css calc() should work with var() too. However, multiplying var() is working well.

So my current workaround is

:root {
    --iconSize: 14px;
    --lineHeight: calc(var(--iconSize) * .125);
}
Semigradsky commented 6 years ago

My result:

:root {
    --iconSize: 14px;
    --lineHeight: 1.75px;
    --lineHeight: NaN;
}

I will investigate.

Semigradsky commented 6 years ago

https://github.com/postcss/postcss-calc/issues/44

MoOx commented 6 years ago
:root {
    --iconSize: 14px;
    --lineHeight: calc(var(--iconSize) * .125);
}

body {
line-height: var(--lineHeight)
}

gives

body {
line-height: 1.75px
}

in the playground, so it might be a recent bug.

Semigradsky commented 6 years ago

Fixed in https://github.com/MoOx/reduce-css-calc/commit/483e3557190a767f2db244c3d9e1e00feeacae68 Just reinstall reduce-css-calc dependency