* Mostly based on other plugins and functions (linted and optimized a little).
* Sources cited inline.
*/
-( function ( $ ) {
+( function () {
/**
* @class jQuery.colorUtil
* @singleton
if ( color && Array.isArray( color ) && color.length === 3 ) {
return color;
}
+ if ( typeof color !== 'string' ) {
+ return undefined;
+ }
// Look for rgb(num,num,num)
// eslint-disable-next-line no-cond-assign
// Look for rgb(num%,num%,num%)
// eslint-disable-next-line no-cond-assign
- if ( result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec( color ) ) {
+ if ( result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)%\s*,\s*([0-9]+(?:\.[0-9]+)?)%\s*,\s*([0-9]+(?:\.[0-9]+)?)%\s*\)/.exec( color ) ) {
return [
parseFloat( result[ 1 ] ) * 2.55,
parseFloat( result[ 2 ] ) * 2.55,
}
// Otherwise, we're most likely dealing with a named color
- return $.colorUtil.colors[ $.trim( color ).toLowerCase() ];
+ return $.colorUtil.colors[ color.trim().toLowerCase() ];
},
/**
};
-}( jQuery ) );
+}() );