Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minifying nested CSS is broken #377

Open
PoseidonEnergy opened this issue Nov 29, 2023 · 1 comment
Open

Minifying nested CSS is broken #377

PoseidonEnergy opened this issue Nov 29, 2023 · 1 comment

Comments

@PoseidonEnergy
Copy link

PoseidonEnergy commented Nov 29, 2023

✅ This CSS minifies correctly:

var css = """
.someClass > * {
    width:calc(50% - (10px / 2));
}
""";
var minified = NUglify.Uglify.Css(css).Code;
Console.WriteLine(minified);

Output: .someClass>*{width:calc(50% - (10px/2))}


❌ The same CSS does not minify correctly if nesting is involved:

var css = """
:nth-child(n){
    .someClass > * {
        width:calc(50% - (10px / 2));
    }
}
""";
var minified = NUglify.Uglify.Css(css).Code;
Console.WriteLine(minified);

Output: :nth-child(n){.someClass> * {width:calc(50% -(10px / 2));}}

In the output, notice the white space around the asterisk was not removed, and the calc() statement was broken (the space after the minus sign should not have been removed).

CSS nesting is relatively new so it's understandable that it's not supported yet. To learn more about CSS nesting click here: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_nesting/Using_CSS_nesting

@trullock
Copy link
Owner

Yeah nesting is completely unsupported

PRs welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants