abiA
Denoβ€’3y agoβ€’
5 replies
abi

Using querySelector on Node

I am doing something like:
const nodeList: NodeList = document.querySelectorAll(".foo");
const nodes = [...nodeList];
const result = nodes.map((n: Node) => n.querySelector("span"));

The above will not work because querySelector is not from Node, but rather Element. Is there any good way to do this without manually tossing around Nodes?
Was this page helpful?