Skip to content

I can't access other elements outside the shadow root #927

Discussion options

You must be logged in to vote

To achieve this. I had to first select the parent element holding both my anchor and the <plasmo-csui> web component, then I proceeded to query the shadowRoot

Here's a high-level overview of what my snippet looks like.

export const getInlineAnchorList: PlasmoGetInlineAnchorList = async () => {
  const anchors = document.querySelectorAll("#anchor")

  return Array.from(anchors).map((element) => {
    const tweetContainer = element.closest("container")
    const closest = element.parentElement.querySelector("plasmo-csui")

    if (closest) {
      if (closest.shadowRoot) {
        const shadowRoot = closest.shadowRoot
        const content = shadowRoot.querySelector("#plasmo-inline")

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kaf-lamed-beyt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant