diff --git a/tinycolor.js b/tinycolor.js index 9580299..4370be5 100644 --- a/tinycolor.js +++ b/tinycolor.js @@ -13,9 +13,9 @@ var trimLeft = /^\s+/, mathRandom = Math.random; function tinycolor (color, opts) { - + color = (color) ? color : ''; - opts = opts || { }; + opts = opts || {'preserve': false}; // If input is already a tinycolor, return itself if (color instanceof tinycolor) { @@ -44,8 +44,11 @@ function tinycolor (color, opts) { if (this._g < 1) { this._g = mathRound(this._g); } if (this._b < 1) { this._b = mathRound(this._b); } - this._ok = rgb.ok; + this._ok = opts.preserve?opts.ok:rgb.ok; + opts.preserve = false; + opts.ok = this._ok; this._tc_id = tinyCounter++; + this._opts = opts; } tinycolor.prototype = { @@ -210,7 +213,8 @@ tinycolor.prototype = { return formattedString || this.toHexString(); }, clone: function() { - return tinycolor(this.toString()); + this._opts.preserve = true; + return tinycolor(this.toString(), this._opts); }, _applyModification: function(fn, args) {