8

I am trying to access a button (class bt-close-onboarding) inside shadow-root using document.querySelector, but when I try to access the shadow-root, it returns null

enter image description here

I startet building the query like this:

document.querySelector('body > brad-root > div.center > #app-wrapper > brad-app-home > )

but when i insert shadow-root in the query it returns null

polonio
  • 333
  • 3
  • 11
  • `shadow-root` is not an element on its own and can't be used in selectors. There is a `shadowRoot` propertty of custom elements, i.e. `const appRoot = document.querySelector('brad-app-home').shadowRoot` then `appRoot.querySelector('.bt-close-onboarding')` – pawel Jul 14 '20 at 14:39
  • 1
    did you manage to solve this? – Doom Nov 10 '20 at 16:07
  • answered here: https://stackoverflow.com/questions/57813144/how-to-select-element-inside-open-shadow-dom-from-document – kolypto Jan 12 '22 at 13:37
  • Does this answer your question? [How to select element inside open Shadow DOM from Document?](https://stackoverflow.com/questions/57813144/how-to-select-element-inside-open-shadow-dom-from-document) – cascading-jox May 30 '22 at 13:19
  • 2
    Please [edit] your post to add code and data as text ([using code formatting](https://stackoverflow.com/editing-help#code)), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and [many more reasons](https://meta.stackoverflow.com/a/285557). Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data. See [mcve] on what code is required. – Adriaan Dec 01 '22 at 12:48

0 Answers0