postcss / postcss-custom-properties

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

Multiple custom properties within linear gradient fails #150

Closed BPScott closed 5 years ago

BPScott commented 5 years ago

This issue originally began "Adding some CSS to a brand new create-react-app project makes the build fail". After a few hours I eventually got here (via postcss-preset-env) with what I believe is the most minimal test case.

Add the following to the bottom of test/basic.css and note that running npm test fails:

.test--linear-gradient {
    background-image: linear-gradient(to right, var(--color, transparent) 0%, var(--color, transparent) 100%);
}

Expected output (to be added at the bottom of test/basic.expect.css:

.test--linear-gradient {
    background-image: linear-gradient(to right, rgb(255, 0, 0) 0%, rgb(255, 0, 0) 100%);
    background-image: linear-gradient(to right, var(--color, transparent) 0%, var(--color, transparent) 100%);
}

Actual output running npm test:

Lots of errors stating Cannot set property 'parent' of undefined


The reproduction for the root issue that started me down this merry path:

jonathantneal commented 5 years ago

This was such a well written bug that I took a few moments to look at the problem, found where it came from in the code, and fixed it. Even better, the fix happens to improve the performance of the plugin!

So, this is resolved by https://github.com/postcss/postcss-custom-properties/commit/7b9b84ba61a6e7f151b7ce88226d610a9122fa34 and has been published in v8.0.9.