querySelectorAll should return Elements
theqp opened this issue · 5 comments
- It's inconsistent with
querySelector
which returnsElement
- It's inconsistent with the MDN Web Docs
A non-live NodeList containing one Element object for each element that matches at least one of the specified selectors or an empty NodeList in case of no matches.
querySelectorAll
returns a NodeList of Element-s:
def querySelectorAll(selectors: String): NodeList = js.native
This matches what the MDN page that you quoted says that the JavaScript method returns.
I'm not sure what you mean by "inconsistent with querySelector
", but scala-js-dom doesn't have a choice here. This interface follows the design of the underlying Javascript methods. Javascript querySelectorAll
method returns a NodeList, and that's what scala-js-dom has to return as well for that method definition.
@raquo The definition of NodeList
is:
class NodeList extends DOMList[Node]
The MDN documentations states querySelector
returns Element
s, not Node
s thus I think it should return DOMList[Element]
Ah, I see what you mean now.
I guess one way to encode it would be class NodeList[N <: Node] extends DOMList[N]
.
@raquo
We already have an equivalent
trait NodeListOf[TNode <: Node] extends DOMList[TNode]