diff --git a/index.js b/index.js index abaa7fe..c756588 100644 --- a/index.js +++ b/index.js @@ -39,7 +39,7 @@ function Color(obj, model) { var i; var channels; - if (typeof obj === 'undefined') { + if (obj == null) { // eslint-disable-line no-eq-null,eqeqeq this.model = 'rgb'; this.color = [0, 0, 0]; this.valpha = 1; diff --git a/test/index.js b/test/index.js index bc563bc..b07a9a0 100644 --- a/test/index.js +++ b/test/index.js @@ -16,6 +16,14 @@ it('Color() instance', function () { notStrictEqual(c.rgb(), c.rgb()); }); +it('Color() instance (null)', function () { + ok((new Color(null)) instanceof Color); +}); + +it('Color() instance (undefined)', function () { + ok((new Color(undefined)) instanceof Color); +}); + it('Immutability', function () { var c = Color(0xFF0000); ok(c !== c.rgb());