Skip to content

Commit 5aa4d57

Browse files
committed
Fix possible edge cases
1 parent 9c5683d commit 5aa4d57

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/lib/gl_format_color.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var rgba = require('color-rgba');
1515
var Colorscale = require('../components/colorscale');
1616
var colorDflt = require('../components/color/attributes').defaultLine;
1717

18+
var colorDfltRgba = rgba(colorDflt);
1819
var opacityDflt = 1;
1920

2021
function calculateColor(colorIn, opacityIn) {
@@ -24,7 +25,7 @@ function calculateColor(colorIn, opacityIn) {
2425
}
2526

2627
function validateColor(colorIn) {
27-
return rgba(colorIn) || rgba(colorDflt);
28+
return rgba(colorIn) || colorDfltRgba;
2829
}
2930

3031
function validateOpacity(opacityIn) {
@@ -48,11 +49,15 @@ function formatColor(containerIn, opacityIn, len) {
4849
)
4950
);
5051
}
51-
else sclFunc = validateColor;
52+
else {
53+
sclFunc = function (c) {
54+
return c;
55+
};
56+
}
5257

5358
if(isArrayColorIn) {
5459
getColor = function(c, i) {
55-
return c[i] === undefined ? colorDflt : sclFunc(c[i]);
60+
return c[i] === undefined ? colorDfltRgba : rgba(sclFunc(c[i]));
5661
};
5762
}
5863
else getColor = validateColor;

0 commit comments

Comments
 (0)