I am using an Aura-based experience builder site. On the site I have a lwc that I have…
- User
I am using an Aura-based experience builder site. On the site I have a lwc that I have enabled Light DOM for. I am doing this because I want to target a child button element from a sibling Aura component that is using an external Js library called IntroJS. IntroJs needs to target an element in order to attatch tour steps.
After enabling the Light DOM, I am able to enter the chrome console and use document.Query selector and I get a result however when I use document.querySelector from the Aura component I get null. Why is that?
Assistant
There could be several reasons why you are getting null when using document.querySelector from your Aura component, even though you are able to select the element using the Chrome console. Here are a few possible explanations:
-
Scope: The Light DOM of a Lightning Web Component is not visible to the Shadow DOM of an Aura component. This means that the Aura component may not be able to access the Light DOM elements of the LWC, and therefore, the element you are trying to target may be invisible to the Aura component.
-
Timing: It's possible that the element you are trying to target is not yet available when the Aura component is trying to access it. This could be due to the element being dynamically created or because the page has not finished loading.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.