From 37dec3cf07506aa29f2a565de76ab3e0e1f2683a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Legan=C3=A9s-Combarro=20=27piranna?= Date: Tue, 30 Mar 2021 09:27:07 +0200 Subject: [PATCH] Don't remove Element from DOM when calling `destroy()` Fix #26 --- index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 56501c6..cb8ffe6 100644 --- a/index.js +++ b/index.js @@ -258,7 +258,19 @@ P2PGraph.prototype.destroy = function () { var self = this debug('destroy') - self._root.remove() + const {_model} = self + + if (_model.focused) { + _model.focused = null + + self.emit('select', false) + } + + _model.links = [] + _model.nodes = [] + + self._update() + window.removeEventListener('resize', self._resizeThrottled) self._root = null