From e9422e8e8dca10347e133582c4c4ca11614f812b Mon Sep 17 00:00:00 2001 From: Ryan Taylor Date: Mon, 5 Nov 2018 14:08:06 -0500 Subject: [PATCH 1/2] 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 54a5d5a..24b8c54 100644 --- a/src/NewWindow.js +++ b/src/NewWindow.js @@ -34,7 +34,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 @@ -98,7 +98,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. @@ -200,7 +200,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 => { @@ -221,13 +221,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 From 3a357962e081bb9c8ec9a92c6267cc236b40c44d Mon Sep 17 00:00:00 2001 From: Wei-Cheng Pan Date: Fri, 12 Apr 2019 16:58:51 +0900 Subject: [PATCH 2/2] fix IE11 problems 1. IE11 cannot access cssText for keyframes rules 2. performance problem in IE11 --- src/NewWindow.js | 90 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 70 insertions(+), 20 deletions(-) diff --git a/src/NewWindow.js b/src/NewWindow.js index 24b8c54..b886144 100644 --- a/src/NewWindow.js +++ b/src/NewWindow.js @@ -191,6 +191,9 @@ NewWindow.propTypes = { */ function copyStyles(source, target) { + // Store style tags, avoid reflow in the loop + const headFrag = target.createDocumentFragment() + Array.from(source.styleSheets).forEach(styleSheet => { // For