From 866e12dc27f07fe6dde3521f70db23239cb9d463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 24 Apr 2019 16:17:27 +0200 Subject: [PATCH] [FIX] playground: remove error handler after 100ms The error handler is intended to only detect errors at 'startup', not in the normal course of operation. --- playground/src/app.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/playground/src/app.js b/playground/src/app.js index e44bc201..7a68e3da 100644 --- a/playground/src/app.js +++ b/playground/src/app.js @@ -143,7 +143,7 @@ class App extends owl.Component { const iframe = document.createElement("iframe"); iframe.onload = () => { - const doc = iframe.contentWindow.document; + const doc = iframe.contentDocument; // inject js const owlScript = doc.createElement("script"); owlScript.type = "text/javascript"; @@ -155,9 +155,13 @@ class App extends owl.Component { this.state.js }`; script.innerHTML = content; - iframe.contentWindow.addEventListener("error", e => - this.displayError(e.message) - ); + const errorHandler = e => this.displayError(e.message); + iframe.contentWindow.addEventListener("error", errorHandler); + setTimeout(function() { + if (iframe.contentWindow) { + iframe.contentWindow.removeEventListener("error", errorHandler); + } + }, 100); doc.body.appendChild(script); }); doc.head.appendChild(owlScript);