lightningcss icon indicating copy to clipboard operation
lightningcss copied to clipboard

bad minification for pseudo-elements

Open gtm-nayan opened this issue 2 years ago • 5 comments

.language-diff :where(.inserted::before) {
	content: '+';
}

is minified into

language-diff :where(){content:"+"}

gtm-nayan avatar Aug 21 '23 15:08 gtm-nayan

Pseudo elements are not allowed inside :where() so this code is invalid. If you ran it in the browser the selector would also not apply.

devongovett avatar Aug 21 '23 16:08 devongovett

Ahh, makes sense, sorry.

gtm-nayan avatar Aug 21 '23 17:08 gtm-nayan

This should probably be a warning instead of getting silently removed on minification?

gtm-nayan avatar Aug 21 '23 17:08 gtm-nayan

We've noticed the same behavior.

In such cases, I think it should issue a warning at the least when code is removed or modified and becomes syntactically invalid. Or remain the problematic code as it is instead of silently remove it.

rameel avatar Sep 01 '23 13:09 rameel

It's less that it's being removed and more that it doesn't parse. CSS error recovery is very lenient, and it is ignored just like a browser would. Wiring through the logger to the selector parser might be possible but would take some work.

devongovett avatar Sep 11 '23 01:09 devongovett