From dddf6a5a77821b4671039c58f1f9f58ddc27162e Mon Sep 17 00:00:00 2001 From: willleahy <52716660+willleahy@users.noreply.github.com> Date: Wed, 23 Nov 2022 11:00:27 -0800 Subject: [PATCH] Avoids purging el on unmount if el is not found Fixes an issue where, when changing a route in an SPA, unmount will be called after the page changes and this.el can no longer be found. --- src/factory.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/factory.js b/src/factory.js index 9911014..a73271c 100644 --- a/src/factory.js +++ b/src/factory.js @@ -148,6 +148,10 @@ export default function plotComponentFactory(Plotly) { this.removeUpdateEvents(); + if (!this.el) { + return; + } + Plotly.purge(this.el); }