Skip to content

Commit

Permalink
fix Color(null) not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Jun 3, 2019
1 parent c30f15a commit aa7f3a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit aa7f3a8

Please sign in to comment.