From 55f5ceb85a6262de257af5fcf237095b7a2fb05a Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Tue, 18 Apr 2017 17:54:56 -0500 Subject: [PATCH] fix(external_api): JS error in removeListeners and simplifies dispose --- modules/API/external/external_api.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index d8797e886..6ea00f672 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -319,16 +319,14 @@ class JitsiMeetExternalAPI extends EventEmitter { * @returns {void} */ dispose() { - const frame = document.getElementById(this.frameName); - - this.postis.destroy(); - if (frame) { - frame.src = 'about:blank'; + if (this.postis) { + this.postis.destroy(); + this.postis = null; } - window.setTimeout(() => { - this.iframeHolder.removeChild(this.frame); + this.removeAllListeners(); + if (this.iframeHolder) { this.iframeHolder.parentNode.removeChild(this.iframeHolder); - }, 10); + } } /** @@ -350,6 +348,13 @@ class JitsiMeetExternalAPI extends EventEmitter { return; } + + if (!this.postis) { + logger.error('Cannot execute command using disposed instance.'); + + return; + } + this.postis.send({ method: commands[name], params: args @@ -398,7 +403,7 @@ class JitsiMeetExternalAPI extends EventEmitter { * NOTE: This method is not removed for backward comatability purposes. */ removeEventListener(event) { - this.removeListeners(event); + this.removeAllListeners(event); } /**