Explorar el Código

Merge pull request #1518 from jitsi/fix_removeListeners

fix(external_api): JS error in removeListeners and simplifies dispose
master
Saúl Ibarra Corretgé hace 8 años
padre
commit
607bef8d68
Se han modificado 1 ficheros con 14 adiciones y 9 borrados
  1. 14
    9
      modules/API/external/external_api.js

+ 14
- 9
modules/API/external/external_api.js Ver fichero

@@ -319,16 +319,14 @@ class JitsiMeetExternalAPI extends EventEmitter {
319 319
      * @returns {void}
320 320
      */
321 321
     dispose() {
322
-        const frame = document.getElementById(this.frameName);
323
-
324
-        this.postis.destroy();
325
-        if (frame) {
326
-            frame.src = 'about:blank';
322
+        if (this.postis) {
323
+            this.postis.destroy();
324
+            this.postis = null;
327 325
         }
328
-        window.setTimeout(() => {
329
-            this.iframeHolder.removeChild(this.frame);
326
+        this.removeAllListeners();
327
+        if (this.iframeHolder) {
330 328
             this.iframeHolder.parentNode.removeChild(this.iframeHolder);
331
-        }, 10);
329
+        }
332 330
     }
333 331
 
334 332
     /**
@@ -350,6 +348,13 @@ class JitsiMeetExternalAPI extends EventEmitter {
350 348
 
351 349
             return;
352 350
         }
351
+
352
+        if (!this.postis) {
353
+            logger.error('Cannot execute command using disposed instance.');
354
+
355
+            return;
356
+        }
357
+
353 358
         this.postis.send({
354 359
             method: commands[name],
355 360
             params: args
@@ -398,7 +403,7 @@ class JitsiMeetExternalAPI extends EventEmitter {
398 403
      * NOTE: This method is not removed for backward comatability purposes.
399 404
      */
400 405
     removeEventListener(event) {
401
-        this.removeListeners(event);
406
+        this.removeAllListeners(event);
402 407
     }
403 408
 
404 409
     /**

Loading…
Cancelar
Guardar