From 100b384a4aa88a469e27ff4d404b7266f9e3b9af Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Thu, 30 Jul 2015 12:26:52 +0300 Subject: client/model/core: add a special Node for use for debugging NaN problems --- src/client/model/core.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/client/model/core.js b/src/client/model/core.js index 4a7e9a7d..6bcc708e 100644 --- a/src/client/model/core.js +++ b/src/client/model/core.js @@ -18,6 +18,8 @@ "use strict"; +var DEBUG_NODE_POSITION = false; + /** * core model module - currently unused */ @@ -55,7 +57,25 @@ define(['util'], function(util) { } } - function Node() { + function NodePlain() { + } + function NodeWithNaNXTest() { + Object.defineProperty(this, "x", { + set: function (new_x) { + if (isNaN(new_x) && !isNaN(this._x)) { + console.log('Node ' + this.id + '.x changed to Nan from ' + this._x); + } + this._x = new_x; + }, + get: function () { + return this._x; + } + }); + } + if (DEBUG_NODE_POSITION) { + Node = NodeWithNaNXTest; + } else { + Node = NodePlain; } Node.prototype.equals = function(other_node){ return this.id === other_node.id; -- cgit v1.3.1