Skip to content

anchor for element list #1466

Answered by aklinker1
walkerliu01 asked this question in Q&A
Discussion options

You must be logged in to vote

You can querySelectorAll elements in the list, and create a UI for each one. anchor accepts an HTML element, not just query selectors.

const list items = document.querySelectorAll('li')
items.forEach(li => {
  const ui = createShadowRootUi({
    anchor: li,
  });
  ui.mount()
})

But if you need to create multiple of the same UI, you may want to roll-your-own, more optimized solution. WXT's built-in APIs are more geared toward a single instance of a UI.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by walkerliu01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants