fix: fix parsing rgba error

This commit is contained in:
gloryyin 2022-09-10 14:44:33 +08:00
parent fe69f7c0ad
commit ce32a3240e
2 changed files with 10 additions and 2 deletions

View File

@ -324,8 +324,11 @@ export class Shape<
return this._getCache(SHADOW_RGBA, this._getShadowRGBA); return this._getCache(SHADOW_RGBA, this._getShadowRGBA);
} }
_getShadowRGBA() { _getShadowRGBA() {
if (this.hasShadow()) { if (!this.hasShadow()) {
var rgba = Util.colorToRGBA(this.shadowColor()); return;
}
var rgba = Util.colorToRGBA(this.shadowColor());
if (rgba) {
return ( return (
'rgba(' + 'rgba(' +
rgba.r + rgba.r +

View File

@ -1229,6 +1229,11 @@ describe('Shape', function () {
// reset shadow // reset shadow
circle.shadowColor(null); circle.shadowColor(null);
assert.equal(circle.getShadowRGBA(), undefined); 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 () { it('scale should also effect shadow offset', function () {