From bfbb732d53af5d2c2fd422a2aa42fe44f6b158fc Mon Sep 17 00:00:00 2001 From: archmoj Date: Mon, 22 Jun 2020 17:54:24 -0400 Subject: [PATCH] handle undefined args in Plotly.validate --- src/plot_api/validate.js | 3 +++ test/jasmine/tests/mock_test.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plot_api/validate.js b/src/plot_api/validate.js index f24994ea235..726f2ea7b75 100644 --- a/src/plot_api/validate.js +++ b/src/plot_api/validate.js @@ -39,6 +39,9 @@ var isArrayOrTypedArray = Lib.isArrayOrTypedArray; * error message (shown in console in logger config argument is enable) */ module.exports = function validate(data, layout) { + if(data === undefined) data = []; + if(layout === undefined) layout = {}; + var schema = PlotSchema.get(); var errorList = []; var gd = {_context: Lib.extendFlat({}, dfltConfig)}; diff --git a/test/jasmine/tests/mock_test.js b/test/jasmine/tests/mock_test.js index 9b4280441dc..8954945fbe8 100644 --- a/test/jasmine/tests/mock_test.js +++ b/test/jasmine/tests/mock_test.js @@ -2078,7 +2078,7 @@ describe('@noCI mock validation', function() { it('validating mock: "' + name + '"', function() { var out = Plotly.validate( figure.data, - figure.layout || {} // shouldn't Plotly.validate handle undefined layout? + figure.layout ); assert(name, out); });