postcss / postcss-custom-properties

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

Nested custom properties with preserve false does not work correctly #233

Open Dai7Igarashi opened 3 years ago

Dai7Igarashi commented 3 years ago

In fallback pattern using "preserve: false", custom properties remain and "root" is deleted, so it can't check the custom properties like below.

[preserve: false]

▼ before
:root {
  --my-blue: blue;
}

// "--my-red" does not exist
.sample {
  color: var(--my-red, var(--my-blue))
}

▼ after
.sample {
  color: var(--my-blue) <-- can't resolve the custom properties
}

if "preserve: true", it's ok.

[preserve: true]

▼ before
:root {
  --my-blue: blue;
}

// "--my-red" does not exist
.sample {
  color: var(--my-red, var(--my-blue))
}

▼ after
:root {
  --my-blue: blue;
}
.sample {
  color: var(--my-blue) <-- it can resolve the custom properties
}
msereniti commented 2 years ago

Upvote this issue