Make getHoverColor() return the original value if it is CanvasGradient (#5865)

This commit is contained in:
Akihiko Kusanagi 2018-11-28 08:54:03 +08:00 committed by Evert Timberg
parent f5437fe548
commit 241499d27f
2 changed files with 8 additions and 1 deletions

View File

@ -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();
};

View File

@ -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)';