diff --git a/src/Shape.ts b/src/Shape.ts index 95da9a54..c5e4c551 100644 --- a/src/Shape.ts +++ b/src/Shape.ts @@ -324,8 +324,11 @@ export class Shape< return this._getCache(SHADOW_RGBA, this._getShadowRGBA); } _getShadowRGBA() { - if (this.hasShadow()) { - var rgba = Util.colorToRGBA(this.shadowColor()); + if (!this.hasShadow()) { + return; + } + var rgba = Util.colorToRGBA(this.shadowColor()); + if (rgba) { return ( 'rgba(' + rgba.r + diff --git a/test/unit/Shape-test.ts b/test/unit/Shape-test.ts index 2e616c18..421a2476 100644 --- a/test/unit/Shape-test.ts +++ b/test/unit/Shape-test.ts @@ -1229,6 +1229,11 @@ describe('Shape', function () { // reset shadow circle.shadowColor(null); assert.equal(circle.getShadowRGBA(), undefined); + + // illegal color + circle.shadowColor('#0000f'); + assert.equal(circle.hasShadow(), true); + assert.equal(circle.getShadowRGBA(), undefined); }); it('scale should also effect shadow offset', function () {