Skip to content

Can Custom Elements use other custom elements

Gabriel Forti edited this page Jul 30, 2018 · 3 revisions

Custom elements can use other custom elements.

<todo-list>
    <todo-item>Item 1</todo-item>
    <todo-item>Item 2</todo-item>
    <todo-item>Item 3</todo-item>
    <todo-item>Item 4</todo-item>
</todo-list>

Since the element in a child, you can access the element from the query selector

this.shadowRoot.querySelectorAll('todo-item');
Clone this wiki locally