From 9014f43d8f7d84ace1aa922a7e64a22f44e687b2 Mon Sep 17 00:00:00 2001 From: Akihiko Kusanagi Date: Wed, 28 Nov 2018 08:54:03 +0800 Subject: [PATCH] Make getHoverColor() return the original value if it is CanvasGradient (#5865) --- src/core/core.helpers.js | 2 +- test/specs/core.helpers.tests.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/core.helpers.js b/src/core/core.helpers.js index 3b1eca5edb3..ca8a7d20c38 100644 --- a/src/core/core.helpers.js +++ b/src/core/core.helpers.js @@ -647,7 +647,7 @@ module.exports = function() { helpers.getHoverColor = function(colorValue) { /* global CanvasPattern */ - return (colorValue instanceof CanvasPattern) ? + return (colorValue instanceof CanvasPattern || colorValue instanceof CanvasGradient) ? colorValue : helpers.color(colorValue).saturate(0.5).darken(0.1).rgbString(); }; diff --git a/test/specs/core.helpers.tests.js b/test/specs/core.helpers.tests.js index 70f0981df0e..796148aaf6c 100644 --- a/test/specs/core.helpers.tests.js +++ b/test/specs/core.helpers.tests.js @@ -848,6 +848,13 @@ describe('Core helper tests', function() { }; }); + it('should return a CanvasGradient when called with a CanvasGradient', function() { + var context = document.createElement('canvas').getContext('2d'); + var gradient = context.createLinearGradient(0, 1, 2, 3); + + expect(helpers.getHoverColor(gradient) instanceof CanvasGradient).toBe(true); + }); + it('should return a modified version of color when called with a color', function() { var originalColorRGB = 'rgb(70, 191, 189)';