diff --git a/lib/network/Network.js b/lib/network/Network.js index f5980b20..486a8a21 100644 --- a/lib/network/Network.js +++ b/lib/network/Network.js @@ -154,6 +154,10 @@ Emitter(Network.prototype); * @param {Object} options */ Network.prototype.setOptions = function (options) { + if (options === null) { + options = undefined; // This ensures that options handling doesn't crash in the handling + } + if (options !== undefined) { let errorFound = Validator.validate(options, allOptions); if (errorFound === true) { diff --git a/test/Network.test.js b/test/Network.test.js index 19ea7428..b9f191c4 100644 --- a/test/Network.test.js +++ b/test/Network.test.js @@ -395,6 +395,25 @@ describe('Network', function () { createSampleNetwork(options); }); + + it('can deal with null data', function() { + // While we're at it, try out other silly values as well + // All the following are wrong, but none should lead to a crash + var awkwardData = [ + null, + [1,2,3], + 42, + 'meow' + ]; + + var container = document.getElementById('mynetwork'); + + for (var n = 0; n < awkwardData.length; ++n) { + var network = new vis.Network(container, awkwardData[n], {}); // Should not throw + } + }); + + describe('Node', function () { it('has known font options', function () {