From 4156c25f42d5812e60e8ce18410fb46ffb1ced61 Mon Sep 17 00:00:00 2001 From: Ryan Taylor Date: Mon, 5 Nov 2018 14:08:06 -0500 Subject: [PATCH] Fix creating new window does not work in Edge --- src/NewWindow.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/NewWindow.js b/src/NewWindow.js index 6ff6592..5062ded 100644 --- a/src/NewWindow.js +++ b/src/NewWindow.js @@ -33,7 +33,7 @@ class NewWindow extends React.PureComponent { */ constructor(props) { super(props) - this.container = document.createElement('div') + this.container = null this.window = null this.windowCheckerInterval = null this.released = false @@ -97,7 +97,7 @@ class NewWindow extends React.PureComponent { // Open a new window. this.window = window.open(url, name, toWindowFeatures(features)) - + this.container = this.window.document.createElement('div') // When a new window use content from a cross-origin there's no way we can attach event // to it. Therefore, we need to detect in a interval when the new window was destroyed // or was closed. @@ -194,7 +194,7 @@ function copyStyles(source, target) { console.error(err) } if (rules) { - const newStyleEl = source.createElement('style') + const newStyleEl = target.createElement('style') // Write the text of each rule into the body of the style element Array.from(styleSheet.cssRules).forEach(cssRule => { @@ -215,13 +215,13 @@ function copyStyles(source, target) { }) .join('url(') } - newStyleEl.appendChild(source.createTextNode(returnText)) + newStyleEl.appendChild(target.createTextNode(returnText)) }) target.head.appendChild(newStyleEl) } else if (styleSheet.href) { // for elements loading CSS from a URL - const newLinkEl = source.createElement('link') + const newLinkEl = target.createElement('link') newLinkEl.rel = 'stylesheet' newLinkEl.href = styleSheet.href