diff --git a/src/NewWindow.js b/src/NewWindow.js index 54a5d5a..b886144 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. @@ -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