From e2a118e43e60f7f88b3db982802876e0dee1d561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 9 Apr 2013 17:43:18 -0700 Subject: [PATCH] Make sure color components cannot be anything else than numbers. --- src/style/Color.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/style/Color.js b/src/style/Color.js index 541f72c9..ac4524ac 100644 --- a/src/style/Color.js +++ b/src/style/Color.js @@ -240,7 +240,8 @@ var Color = this.Color = Base.extend(new function() { : name === 'hue' ? function(value) { // Keep negative values within modulo 360 too: - return ((value % 360) + 360) % 360; + return isNaN(value) ? 0 + : ((value % 360) + 360) % 360; } : type === 'gradient' ? function(value) { @@ -249,7 +250,8 @@ var Color = this.Color = Base.extend(new function() { name === 'highlight'); } : function(value) { - return Math.min(Math.max(value, 0), 1); + return isNaN(value) ? 0 + : Math.min(Math.max(value, 0), 1); }; this['get' + part] = function() {