diff --git a/src/color.js b/src/color.js index 1464d88..380be0b 100644 --- a/src/color.js +++ b/src/color.js @@ -12,7 +12,7 @@ class Color { #red; #green; #blue; - #hex; + _hex; /** * @@ -40,7 +40,10 @@ class Color { * @returns */ hex(hexcode) { - this.#hex = hexcode; + if (!hexcode.startsWith('#')) { + hexcode = '#' + hexcode; + } + this._hex = hexcode; return this; } } diff --git a/src/modifier.js b/src/modifier.js index 691a032..b48934b 100644 --- a/src/modifier.js +++ b/src/modifier.js @@ -174,11 +174,15 @@ class Modifier { * @returns {Modifier} this modifier object */ background(color) { - this._modifications["background-color"] = ( - color - ? color.cssRGBString() - : "inherit" - ); + if (color) { + if (color._hex) { + this._modifications["background-color"] = color._hex; + } else { + this._modifications["background-color"] = color.cssRGBString(); + } + } else { + this._modifications["background-color"] = "inherit"; + } return this; }