From ac3070f822673ec233bace8dfa407831a6c8d6d7 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Fri, 21 Nov 2014 21:10:01 -0500 Subject: [PATCH] Make invalid option throw --- auto_tests/tests/dygraph-options-tests.js | 5 ++++- dygraph-options.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/auto_tests/tests/dygraph-options-tests.js b/auto_tests/tests/dygraph-options-tests.js index 094ebd6..7222a21 100644 --- a/auto_tests/tests/dygraph-options-tests.js +++ b/auto_tests/tests/dygraph-options-tests.js @@ -64,7 +64,10 @@ var getWarnings = function(div, data, opts) { console.warn = function(message) { warnings.push(message.replace(/ \(.*/, '')); }; - new Dygraph(graph, data, opts); + try { + new Dygraph(graph, data, opts); + } catch (e) { + } console.warn = oldWarn; return warnings; }; diff --git a/dygraph-options.js b/dygraph-options.js index 1dff17a..413b9ea 100644 --- a/dygraph-options.js +++ b/dygraph-options.js @@ -432,14 +432,14 @@ var WARNINGS = {}; // Only show any particular warning once. */ DygraphOptions.prototype.warnInvalidOption_ = function(optionName) { if (!WARNINGS[optionName]) { + WARNINGS[optionName] = true; var isSeries = (this.labels_.indexOf(optionName) >= 0); if (isSeries) { console.warn('Use new-style per-series options (saw ' + optionName + ' as top-level options key). See http://bit.ly/1tceaJs'); } else { console.warn('Unknown option ' + optionName + ' (full list of options at dygraphs.com/options.html'); - // throw "invalid option " + optionName; + throw "invalid option " + optionName; } - WARNINGS[optionName] = true; } }; -- 2.7.4