Skip to content

Commit

Permalink
fix getEventSourceWrapper window on iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
minimit committed May 8, 2019
1 parent fe33d59 commit 9305296
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 9305296

Please sign in to comment.