Are Targets always in document order?


#1

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 : https://www.w3.org/TR/selectors-api/#queryselectorall)
Can we be sure that if I do a this.listItemTargets as a selectpr my result will be also in Document Order?


#2

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


#3

Excellent, thanks for your prompt response


Finding targets within another target