title: Inject library wrapped with IIFE to child window opened with React app
body: <p>I have library which wrapped with an <a href="https://developer.mozilla.org/en-US/docs/Glossary/IIFE" rel="nofollow noreferrer">IIFE</a> and placed to .js file,and it looks and works generally in this way:</p>
  <pre><code>(function (libraryObject) {
  
      libraryObject.doSomething = function (){
      document.getElementById() ....
  }
  
  
  
  })((window.library = window.library || {}));
  </code></pre>
  <p>When I import it to my React app I just do:
  <code> import './library'</code></p>
  <p>So it injects to window in which my React app initialized.</p>
  <p>And <strong>document</strong> object also belongs to this window and when I call for ex:</p>
  <p><code> window.library.doSomething()</code>
  It will work with context of this <strong>document</strong>, so <code>document.getElementById() ....</code> inside library will work with the same document.</p>
  <p>But I need open an child popup with <code>const myChildPopup =  window.open()</code> and inject this library in context of my child popup and next library can do something in <strong>document</strong> of my child popup, something like this:</p>
  <p><code>myChildPopup.libraryObject.doSomething()</code>.</p>
  <p>So that the document object in this case inside library will reffer  <code>myChildPopup.document</code>. For ex:
  <code>document.getElementById() ....   // document === myChildPopup.document</code></p>
  <p>Any ideas how to do this?</p>