The definitions from the DOM Standard seems almost exactly the same, and I don't understand the difference.
What is the difference between queryAll
and querySelectorAll
.
The evaluation logic from DOM standard is below, but I am not smart enough to understand it.
query
& queryAll
To match a relative selectors string relativeSelectors against a set, run these steps:
Let s be the result of parse a relative selector from relativeSelectors against set. [SELECTORS]
If s is failure, throw a JavaScript TypeError.
Return the result of evaluate a selector s using :scope elements set. [SELECTORS]
The query(relativeSelectors) method must return the first result of running match a relative selectors string relativeSelectors against a set consisting of context object, and null if the result is an empty list.
The queryAll(relativeSelectors) method must return an Elements array initialized with the result of running match a relative selectors string relativeSelectors against a set consisting of context object.
querySelector
& querySelectorAll
To scope-match a selectors string selectors against a node, run these steps:
Let s be the result of parse a selector selectors. [SELECTORS]
If s is failure, throw a JavaScript TypeError.
Return the result of evaluate a selector s against node's root using scoping root node and scoping method scope-filtered. [SELECTORS].
The querySelector(selectors) method must return the first result of running scope-match a selectors string selectors against the context object, and null if the result is an empty list otherwise.
The querySelectorAll(selectors) method must return the static result of running scope-match a selectors string selectors against the context object.
Elements
array, which contains live nodes and the other returns a staticNodeList
. – Cumulous