myFavShrimp / turf

Macro based compile-time SCSS transpilation, CSS minification, and class name uniquification toolchain inspired by CSS modules.
MIT License
50 stars 2 forks source link

CSS Class selector support #18

Closed BToersche closed 4 months ago

BToersche commented 4 months ago

In CSS you can use selectors like this not selector: li:not(.test). Currently turf does not replace these with the correct (randomized) classes for the class names within such selector. For instance:

inline_style_sheet! {
    .test {
        color: #000;
    }
    li:not(.test) {
        color: #ccc;
    }
}

Does not get compiled correctly to the correct class name. It should become something like:

.my-class-348652795 {
    color: #000;
}
li:not(.my-class-348652795) {
    color: #ccc;
}

But instead gets compiled to:

.my-class-348652795 {
    color: #000;
}
li:not(.test) { // Note that this class selector has the wrong name.
    color: #ccc;
}
BToersche commented 4 months ago

I've resolved the issue. PR is ready for review and can be found here: https://github.com/myFavShrimp/turf/pull/19

myFavShrimp commented 4 months ago

Thank you for creating an issue and the corresponding pr. I merged the pull request so this issue can be closed now. Thanks again!