From 3bb867890fb8e1a5fa2d244a36c675e8d7bbe39c Mon Sep 17 00:00:00 2001 From: jos Date: Fri, 20 Jun 2014 09:45:14 +0200 Subject: [PATCH] Throws an error when constructing without new keyword. --- HISTORY.md | 17 ++++++++++++++++- src/graph/Graph.js | 3 +++ src/graph3d/Graph3d.js | 4 ++++ src/timeline/Timeline.js | 4 ++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index c859d549..d9085c83 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,7 +2,22 @@ http://visjs.org -## not yet released, version 2.0.0 +## 2014-06-19, version 2.0.1 + +### Timeline + +- Throws an error when constructing without new keyword. + +### Graph + +- Throws an error when constructing without new keyword. + +### Graph3d + +- Throws an error when constructing without new keyword. + + +## 2014-06-19, version 2.0.0 ### Timeline diff --git a/src/graph/Graph.js b/src/graph/Graph.js index ee68da20..084d2261 100644 --- a/src/graph/Graph.js +++ b/src/graph/Graph.js @@ -10,6 +10,9 @@ * @param {Object} options Options */ function Graph (container, data, options) { + if (!(this instanceof Graph)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } this._initializeMixinLoaders(); diff --git a/src/graph3d/Graph3d.js b/src/graph3d/Graph3d.js index 21e3f5d1..c246b380 100644 --- a/src/graph3d/Graph3d.js +++ b/src/graph3d/Graph3d.js @@ -10,6 +10,10 @@ * @param {Object} [options] */ function Graph3d(container, data, options) { + if (!(this instanceof Graph3d)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + // create variables and set default values this.containerElement = container; this.width = '400px'; diff --git a/src/timeline/Timeline.js b/src/timeline/Timeline.js index 38299f77..9706bc96 100644 --- a/src/timeline/Timeline.js +++ b/src/timeline/Timeline.js @@ -6,6 +6,10 @@ * @constructor */ function Timeline (container, items, options) { + if (!(this instanceof Timeline)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + var me = this; this.defaultOptions = { start: null,