From: Dan Vanderkam Date: Sat, 22 Nov 2014 02:10:01 +0000 (-0500) Subject: Make invalid option throw X-Git-Tag: v1.1.0~19^2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=refs%2Fheads%2Fchecked-options;p=dygraphs.git Make invalid option throw --- 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; } };