anchor for element list #1466
Answered
by
aklinker1
walkerliu01
asked this question in
Q&A
-
Assuming I want to add some content to each element in the list, what should I do? I tested that ahchor only works for the first element in the list |
Beta Was this translation helpful? Give feedback.
Answered by
aklinker1
Mar 1, 2025
Replies: 1 comment
-
You can 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. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
walkerliu01
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can
querySelectorAll
elements in the list, and create a UI for each one.anchor
accepts an HTML element, not just query selectors.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.