Merge pull request #1397 from yinguangyao/master

fix: fix parsing rgba error
This commit is contained in:
Anton Lavrenov 2022-09-12 16:18:52 -05:00 committed by GitHub
commit 99180601fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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()) {
return;
}
var rgba = Util.colorToRGBA(this.shadowColor()); 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 () {