trullock / NUglify

NUglify is a HTML, JavaScript and CSS minification Library for .NET (fork of AjaxMin + new features)
Other
396 stars 79 forks source link

Fix for syntax error for rgb with spaces like "rgb(1 3 5)" and 4 part rgb functions which is valid in CSS Color Module 4 #288

Closed volkanceylan closed 2 years ago

volkanceylan commented 2 years ago

CSS minifier reports syntax error with statements like "rgb(var(--rgb-nums))" while it is valid as long as the variable is in an expected format like "1 2 3", "1, 2, 3", "#357", "#335577" etc. It is not possible to validate the variable itself in Nuglify though as its value might be defined elsewhere. This just ignores rgb function with a var function inside.

This pull request also handles the rgb function with spaces, e.g. rgb(3 5 7) as most browsers support this syntax now.

trullock commented 2 years ago

Thanks for your work on this

Can you split this PR up? The RGB with spaces change can be merged straight away.

The variables var feature should probably be more broadly tested, do they really only not work inside rgb? i expect other "functions" like calc might also suffer this, if we can get confidence around this at least whilst we're at it that would be great

volkanceylan commented 2 years ago

OK, i have removed css var related change from this branch, will send a separate pull req after this is merged. And you are right, although not very common it is possible to use other functions inside rgb which Nuglify should simply ignore.

I also added support for 4 part rgb with/without spaces which is supported in CSS Color Module Level 4:

https://www.w3.org/TR/css-color-4/#funcdef-rgb

trullock commented 2 years ago

Published in 1.17.6