1

I have added a script element inside the #shadow-root. The problem is that when the window object is used inside the b2.js file, it still refers to the parent application's window. Is there a way to scope the window object that is used inside the script file to the #shadow-root exclusively.

Example dom: enter image description here

Ovidijus Parsiunas
  • 2,512
  • 2
  • 8
  • 18
  • See: https://stackoverflow.com/questions/63027122/running-a-script-in-the-context-of-an-html-custom-element/63030202#63030202 – Danny '365CSI' Engelman Aug 07 '22 at 18:15
  • Hi @Danny'365CSI'Engelman, thankyou very much for the reply. This appears to be pointing towards the right direction. I have experimented with the example in the question but the ```window``` object still appears to be pointing to the parent application. The root of my problem is that I am inserting external scripts which use the ```window``` and ```document``` objects and need to get access to the elements inside the ```#shadow-root```. Is there any way to get the ```window.document``` object to point to the inside of the ```#shadow-root```. The example you provided only proves it for scope. – Ovidijus Parsiunas Aug 07 '22 at 19:17
  • That is not possible. – Danny '365CSI' Engelman Aug 07 '22 at 19:23
  • Understood. Might you know of another alternative other than iFrames which could potentially facilitate segregated ```window.document``` variables. – Ovidijus Parsiunas Aug 07 '22 at 21:25
  • every DOM has one ``window.document`` – Danny '365CSI' Engelman Aug 08 '22 at 06:56

0 Answers0