Merge pull request #1985 from fredj/named-color

Handle ol.color.ENABLE_NAMED_COLORS = false
This commit is contained in:
Frédéric Junod
2014-04-16 16:28:26 +02:00
2 changed files with 15 additions and 13 deletions
+1 -3
View File
@@ -1,7 +1,5 @@
goog.provide('ol.render.canvas'); goog.provide('ol.render.canvas');
goog.require('ol.color');
/** /**
* @typedef {{fillStyle: string}} * @typedef {{fillStyle: string}}
@@ -39,7 +37,7 @@ ol.render.canvas.defaultFont = '10px sans-serif';
* @const * @const
* @type {ol.Color} * @type {ol.Color}
*/ */
ol.render.canvas.defaultFillStyle = ol.color.fromString('black'); ol.render.canvas.defaultFillStyle = [0, 0, 0, 1];
/** /**
+4
View File
@@ -13,9 +13,11 @@ describe('ol.color', function() {
ol.color.fromStringInternal_.restore(); ol.color.fromStringInternal_.restore();
}); });
if (ol.color.ENABLE_NAMED_COLORS) {
it('can parse named colors', function() { it('can parse named colors', function() {
expect(ol.color.fromString('red')).to.eql([255, 0, 0, 1]); expect(ol.color.fromString('red')).to.eql([255, 0, 0, 1]);
}); });
}
it('can parse 3-digit hex colors', function() { it('can parse 3-digit hex colors', function() {
expect(ol.color.fromString('#087')).to.eql([0, 136, 119, 1]); expect(ol.color.fromString('#087')).to.eql([0, 136, 119, 1]);
@@ -34,6 +36,7 @@ describe('ol.color', function() {
[255, 255, 0, 0.1]); [255, 255, 0, 0.1]);
}); });
if (ol.color.ENABLE_NAMED_COLORS) {
it('caches parsed values', function() { it('caches parsed values', function() {
var count = ol.color.fromStringInternal_.callCount; var count = ol.color.fromStringInternal_.callCount;
ol.color.fromString('aquamarine'); ol.color.fromString('aquamarine');
@@ -41,6 +44,7 @@ describe('ol.color', function() {
ol.color.fromString('aquamarine'); ol.color.fromString('aquamarine');
expect(ol.color.fromStringInternal_.callCount).to.be(count + 1); expect(ol.color.fromStringInternal_.callCount).to.be(count + 1);
}); });
}
it('throws an error on invalid colors', function() { it('throws an error on invalid colors', function() {
var invalidColors = ['tuesday', '#1234567', 'rgb(255.0,0,0)']; var invalidColors = ['tuesday', '#1234567', 'rgb(255.0,0,0)'];