Skip to content

Commit

Permalink
Make getHoverColor() return the original value if it is CanvasGradient (
Browse files Browse the repository at this point in the history
  • Loading branch information
nagix authored and etimberg committed Nov 28, 2018
1 parent 8e35eef commit 9014f43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/core.helpers.js
Expand Up @@ -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();
};
Expand Down
7 changes: 7 additions & 0 deletions test/specs/core.helpers.tests.js
Expand Up @@ -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)';

Expand Down

0 comments on commit 9014f43

Please sign in to comment.