From 9305296a85aea641cf77d78aa6c41e60b2a91c0d Mon Sep 17 00:00:00 2001 From: Riccardo Caroli Date: Wed, 8 May 2019 10:00:58 +0200 Subject: [PATCH] fix getEventSourceWrapper window on iframe --- client.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/client.js b/client.js index abc95ed..d33def3 100644 --- a/client.js +++ b/client.js @@ -117,15 +117,19 @@ function EventSourceWrapper() { } function getEventSourceWrapper() { - if (!window.__whmEventSourceWrapper) { - window.__whmEventSourceWrapper = {}; + var top = window; + if (window.self !== window.top) { + top = window.top; } - if (!window.__whmEventSourceWrapper[options.path]) { + if (!top.__whmEventSourceWrapper) { + top.__whmEventSourceWrapper = {}; + } + if (!top.__whmEventSourceWrapper[options.path]) { // cache the wrapper for other entries loaded on // the same page with the same options.path - window.__whmEventSourceWrapper[options.path] = EventSourceWrapper(); + top.__whmEventSourceWrapper[options.path] = EventSourceWrapper(); } - return window.__whmEventSourceWrapper[options.path]; + return top.__whmEventSourceWrapper[options.path]; } function connect() {