You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's me again (from http://cssminifier.com/). I've been digging through a number of files that get submitted to the site and trying to extract failures I see. This one is fairly simple I think, but the question is what to do with it.
Smallest example that fails:
body {
background:rgba(0255100%);
}
The error is:
Error:TypeError: Cannot call method 'indexOf' of undefined
What's happening is that inside lib/selectors/optimizers/simple.js inside colorMininifier() the following regex is being matched /(rgb|rgba|hsl|hsla)\(([^\)]+)\)/g obviously. However, in the function the colorDef.split(',') only produces one tokens since there are no commas
The function then falls through to the tokens[1] (which is undefined) and therefore the .indexOf() fails with the above statement.
What's the best thing to do here? The rgba(0 255 100%) value is invalid (https://developer.mozilla.org/en/docs/Web/CSS/color_value#rgba%28%29) since it mixes integer and percentage notation. Do we leave it alone and output a warning? Do we try and do something with it, do we just omit it completely? Am asking these questions since I'm sure you've already got procedures for doing something when processing invalid input.
Oh, and I'm happy to create a PR for it too so I can get into it a little bit. :) Cheers.
The text was updated successfully, but these errors were encountered:
From what I can see, the rgb() and rgba() must enclose 3 or 4 integer or percent values. Anything else (including mixing them) is invalid. The example above is therefore wrong in at least three ways:
the values mix both integer and percent values
the values are not separated by a comma
it is rgba but only has three values, not four
I'm afraid I don't have access to many browsers, just Firefox and Chromium on Linux so can't test across browsers/platforms. Any info you can find is much appreciated.
Well I think we should remove the declarations as browsers will ignore them anyways. Let's see if it's easy to do so, otherwise we can also leave them as is.
Hi @jakubpawlowicz,
It's me again (from http://cssminifier.com/). I've been digging through a number of files that get submitted to the site and trying to extract failures I see. This one is fairly simple I think, but the question is what to do with it.
Smallest example that fails:
The error is:
What's happening is that inside
lib/selectors/optimizers/simple.js
insidecolorMininifier()
the following regex is being matched/(rgb|rgba|hsl|hsla)\(([^\)]+)\)/g
obviously. However, in the function thecolorDef.split(',')
only produces onetokens
since there are no commasThe function then falls through to the
tokens[1]
(which is undefined) and therefore the.indexOf()
fails with the above statement.What's the best thing to do here? The
rgba(0 255 100%)
value is invalid (https://developer.mozilla.org/en/docs/Web/CSS/color_value#rgba%28%29) since it mixes integer and percentage notation. Do we leave it alone and output a warning? Do we try and do something with it, do we just omit it completely? Am asking these questions since I'm sure you've already got procedures for doing something when processing invalid input.Oh, and I'm happy to create a PR for it too so I can get into it a little bit. :) Cheers.
The text was updated successfully, but these errors were encountered: