postcss / postcss-custom-properties

Use Custom Properties in CSS
https://postcss.github.io/postcss-custom-properties
MIT License
597 stars 77 forks source link

Unit issue since 8.0.0 #134

Closed henryruhs closed 5 years ago

henryruhs commented 5 years ago

Hello,

I just updated to latest 8.0.0 and get the error:

Cannot read property 'unit' of undefined
radeno commented 5 years ago

Same issue. Paths are trimmed with .../ As you can see, font-family works, background as rgb dont.

{ TypeError: Cannot read property 'unit' of undefined
    at .../src/styles/global.css:55:3
    at new NumberNode (.../node_modules/postcss-values-parser/lib/number.js:10:22)
    at cloneNode (.../node_modules/postcss-values-parser/lib/node.js:4:16)
    at cloned.(anonymous function).value.map.j (.../node_modules/postcss-values-parser/lib/node.js:19:34)
    at Array.map (<anonymous>)
    at cloneNode (.../node_modules/postcss-values-parser/lib/node.js:19:25)
    at cloned.(anonymous function).value.map.j (.../node_modules/postcss-values-parser/lib/node.js:19:34)
    at Array.map (<anonymous>)
    at cloneNode (.../node_modules/postcss-values-parser/lib/node.js:19:25)
    at Value.clone (.../node_modules/postcss-values-parser/lib/node.js:62:18)
    at array.map.node (.../node_modules/postcss-custom-properties/index.cjs.js:184:55)
  postcssNode:
   Declaration {
     raws: { before: '\n  ', between: ': ' },
     type: 'decl',
     parent:
      Rule {
        raws: [Object],
        type: 'rule',
        nodes: [Array],
        parent: [Object],
        source: [Object],
        selector: 'body',
        lastEach: 2,
        indexes: [Object] },
     source: { start: [Object], input: [Object], end: [Object] },
     prop: 'background',
     value: 'var(--site-background)' } }

at global.css

body {
  min-height: 100%;
  margin: 0;
  padding: 0;
  line-height: 1.2;
  font-family: var(--text-font-family);
  font-size: 16px;
  background: var(--site-background);
  color: var(--text-color);
}

definitions


:root {
  --site-background: rgb(255, 255, 255);
  --text-font-family: "Open Sans", system-ui;
  --text-color: rgb(70, 70, 70);
}
jonathantneal commented 5 years ago

This is a bug in postcss-values-parser. I have reported the bug and submitted a PR to fix it. https://github.com/shellscape/postcss-values-parser/pull/55

I’m really surprised this bug was never encountered before. I’m sorry for any issues you’ve had.

Given its critical nature, I may publish a work-around before the maintainers of postcss-values-parser publish a fix.

jonathantneal commented 5 years ago

My fix has been merged, and I have requested a new version of postcss-values-parser be published.

https://github.com/shellscape/postcss-values-parser/pull/56

If it is published, then new installs of v8.0.0 will work again, and I will create a v8.0.1 bump of postcss-custom-properties for good measure.

If it is not published, then I will need to hack the values parser within this plugin until it is published. I would very much prefer not to do this, but for every hour it is not fixed, I expect more unhappy users.

radeno commented 5 years ago

@jonathantneal that was fast. thank you so much!

Ladonasc commented 5 years ago

Thanks @jonathantneal !