css-minify icon indicating copy to clipboard operation
css-minify copied to clipboard

Panic in `Minifier::minify` due to nested selectors

Open NTBBloodbath opened this issue 1 year ago • 0 comments

Hi, I just started using this library and I found a bug that causes the library to panic. This is related to the & nested selectors, maybe the library doesn't support its use?

For example, trying to minify the following CSS code will result in a panic:

#desc > a,
#discord-link > a,
#github-pages > a,
#github-issues > a {
  color: var(--color-blue-400);
  &:hover {
    text-decoration: underline;
  }
}

That code is the equivalent of doing the following and in this case it does work (although it is not very idiomatic in modern CSS):

#desc > a,
#discord-link > a,
#github-pages > a,
#github-issues > a {
  color: var(--color-blue-400);
}

#desc > a:hover,
#discord-link > a:hover,
#github-pages > a:hover,
#github-issues > a:hover {
  text-decoration: underline;
}

Panic logs (using a debug build):

thread 'main' panicked at src/cmd/build.rs:149:22:
called `Result::unwrap()` on an `Err` value: MError { message: "Invalid block at line 1:2", error: "\"#desc > a,\\n#discord-link > a,\\n#github-pages > a,\\n#github-issues > a {\\n  color: var(--color-blue-400);\\n  &:hover {\\n    text-decoration: underline;\\n  }\\n}\\n\"" }

NTBBloodbath avatar Feb 07 '25 22:02 NTBBloodbath