Are Targets always in document order?

In an app I will have plenty of targets of the exact same type within a list (some listItem).
Targets can be appended dynamically to the DOM anywhere in the list.

At some point I need to select all listItems, I need the result array of item to be exactly in the Document Order.

If I do a querySelectorAll the results are in the Document order : (source :
Can we be sure that if I do a this.listItemTargets as a selectpr my result will be also in Document Order?

1 Like

Yes, they’ll always be in the same document order. Target elements are collected using querySelectorAll:


Excellent, thanks for your prompt response