From 7c6993e77beed20098c446737d2b0b60c5e57ae6 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Sun, 28 Apr 2013 14:08:22 -0400 Subject: [PATCH] Fix a regression when no options are provided. --- jquery.flot.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jquery.flot.js b/jquery.flot.js index 447714a..15938fc 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -641,10 +641,13 @@ Licensed under the MIT license. function parseOptions(opts) { $.extend(true, options, opts); - - //Override options.colors after $.extend if user has set colors, because extend does not clear out excess - //default colors if user defines color palette smaller than default palette size (currently 5). - if (opts.colors) { + + // $.extend merges arrays, rather than replacing them. When less + // colors are provided than the size of the default palette, we + // end up with those colors plus the remaining defaults, which is + // not expected behavior; avoid it by replacing them here. + + if (opts && opts.colors) { options.colors = opts.colors; }