MadLittleMods / MadLittleMods/postcss-css-variables

Variable fallback not working

Open
#102 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
551
Forks
63
PR merge metrics
No merged PRs in 30d

Description

I'm using postcss-css-variables with a JSON file with this data:

{
    "variables" : {
        "--color-form-selected" : "red",
        "--color-positive-green" : "green"
   }
}

On this css which uses variable fallbacks but oddly it chooses the last variable provided instead of the first.

.a-checkbox__input:checked ~ .a-checkbox__label {
    background-color: var(--color-form-selected);
    border-color: var(--color-positive-green, var(--color-form-selected));
}

But it outputs

.a-checkbox__input:checked ~ .a-checkbox__label {
    background-color: red;
     border-color: red;
}

Expected

.a-checkbox__input:checked ~ .a-checkbox__label {
    background-color: red;
    border-color: green;
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the JSON variables and CSS fallback example in the issue as a regression case, then trace the plugin's variable-fallback handling. Done means the nested fallback preserves the defined green value and produces the expected CSS output without changing the other variable replacement.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.