If I have a nested set of DOM elements, e.g. ul > li > ul > li and I use the selector li by itself, do either Sizzle or document.querySelectorAll define the order in which the elements will be returned?
Orderings that might be returned include “top most first”, “leaf nodes first”, or just “in document order”, but I’ve never seen anything written down to specify which.
Well, it’s quite clearly said in MDN documentation for
document.querySelectorAll:W3 DOM documentation gives the same description:
In other words, given the following structure:
… result of
document.querySelectorAll('div')should be a NodeList of exactly the following order: