From 18e1d1f2b474927fcd96ad09f174873a4aad23e0 Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Tue, 19 Jan 2016 17:49:58 +0100 Subject: [PATCH] Fixed 1588, destroy now releases the dataset. --- HISTORY.md | 1 + dist/vis.js | 8 +++++++- lib/network/modules/EdgesHandler.js | 4 ++++ lib/network/modules/NodesHandler.js | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index d13c55f3..b5a5e5c8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -12,6 +12,7 @@ http://visjs.org on the manipulation toolbar. - Fixed #1334 (again): Network now ignores scroll when interaction:zoomView is false. - Added options to customize the hierarchical layout without the use of physics. +- Fixed #1588: destroy now unsubscribed from the dataset. ### Graph2d diff --git a/dist/vis.js b/dist/vis.js index 11bfbc55..f4193f82 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -5,7 +5,7 @@ * A dynamic, browser-based visualization library. * * @version 4.12.1-SNAPSHOT - * @date 2016-01-18 + * @date 2016-01-19 * * @license * Copyright (C) 2011-2016 Almende B.V, http://almende.com @@ -28577,6 +28577,9 @@ return /******/ (function(modules) { // webpackBootstrap this.body.emitter.on('refreshNodes', this.refresh.bind(this)); this.body.emitter.on('refresh', this.refresh.bind(this)); this.body.emitter.on('destroy', function () { + util.forEach(_this2.nodesListeners, function (callback, event) { + if (_this2.body.data.nodes) _this2.body.data.nodes.off(event, callback); + }); delete _this2.body.functions.createNode; delete _this2.nodesListeners.add; delete _this2.nodesListeners.update; @@ -31517,6 +31520,9 @@ return /******/ (function(modules) { // webpackBootstrap this.body.emitter.on("refreshEdges", this.refresh.bind(this)); this.body.emitter.on("refresh", this.refresh.bind(this)); this.body.emitter.on("destroy", function () { + util.forEach(_this2.edgesListeners, function (callback, event) { + if (_this2.body.data.edges) _this2.body.data.edges.off(event, callback); + }); delete _this2.body.functions.createEdge; delete _this2.edgesListeners.add; delete _this2.edgesListeners.update; diff --git a/lib/network/modules/EdgesHandler.js b/lib/network/modules/EdgesHandler.js index f66fbe1e..4be26d95 100644 --- a/lib/network/modules/EdgesHandler.js +++ b/lib/network/modules/EdgesHandler.js @@ -141,6 +141,10 @@ class EdgesHandler { this.body.emitter.on("refreshEdges", this.refresh.bind(this)); this.body.emitter.on("refresh", this.refresh.bind(this)); this.body.emitter.on("destroy", () => { + util.forEach(this.edgesListeners, (callback, event) => { + if (this.body.data.edges) + this.body.data.edges.off(event, callback); + }); delete this.body.functions.createEdge; delete this.edgesListeners.add; delete this.edgesListeners.update; diff --git a/lib/network/modules/NodesHandler.js b/lib/network/modules/NodesHandler.js index cbf0450a..f7f6d650 100644 --- a/lib/network/modules/NodesHandler.js +++ b/lib/network/modules/NodesHandler.js @@ -115,6 +115,10 @@ class NodesHandler { this.body.emitter.on('refreshNodes', this.refresh.bind(this)); this.body.emitter.on('refresh', this.refresh.bind(this)); this.body.emitter.on('destroy', () => { + util.forEach(this.nodesListeners, (callback, event) => { + if (this.body.data.nodes) + this.body.data.nodes.off(event, callback); + }); delete this.body.functions.createNode; delete this.nodesListeners.add; delete this.nodesListeners.update;