Simplify Color#initialize() by relying on #convert() for performing _colorType check and delegate to #clone() instead of #convert() if it is the same.

This commit is contained in:
Jürg Lehni 2011-05-26 08:39:21 +01:00
parent bfcfb23a9e
commit 300ea72261

View file

@ -159,11 +159,8 @@ var Color = this.Color = Base.extend(new function() {
} else {
// Called on a subclass instance. Return the converted
// color.
var color = arg._colorType ? arg
: Color.read(arguments, 0, 1);
return (colorType !== color._colorType)
? color.convert(colorType)
: color.clone();
return (arg._colorType ? arg : Color.read(arguments))
.convert(colorType);
}
} else if (typeof arg === 'string') {
var rgbColor = arg.match(/^#[0-9a-f]{3,6}$/i)