MadLittleMods / postcss-css-variables

PostCSS plugin to transform CSS Custom Properties(CSS variables) syntax into a static representation
https://madlittlemods.github.io/postcss-css-variables/playground/
Other
536 stars 62 forks source link

Dependent property redefinition #16

Open bangseongbeom opened 8 years ago

bangseongbeom commented 8 years ago

Dependent property should be redefined if source property is changed.

Input:

.a {
    --source: red;
    --dependent: var(--source);

    color: var(--dependent);
}

.a .b {
    --source: blue;

    color: var(--dependent);
}

Actual:

.a {
    color: red;
}

.a .b {
    color: red;
}

Expected:

.a {
    color: red;
}

.a .b {
    color: blue;
}
MadLittleMods commented 8 years ago

Thank you for the bug report @bangseongbeom :grinning:

Dangoo commented 8 years ago

Any news on this issue?

It occures when overwriting a variable more then one time:

:root {
    --test: 300px;
    --bla: var(--test);
}

div {
    width: var(--test);
}

div.foo {
    --test: 200px;
    width: var(--bla);
}

div.bar {
    --test: 100px;
    width: var(--bla);
}

Actual:

div {
    width: 100px;
}

div.foo {
    width: 100px;
}

div.bar {
    width: 100px;
}

Expected:

div {
    width: 300px;
}

div.foo {
    width: 200px;
}

div.bar {
    width: 100px;
}
MadLittleMods commented 8 years ago

Sorry @Dangoo, postcss-css-variables needs a overhaul and while I have started some of it a while ago, I haven't had a chance to dive back in and get it done. Currently the code is flawed and too brittle which makes fixing these things troublesome.