scala-js/scala-js-dom

Can't use `PimpedNodeList` on `NodeListOf`

Closed this issue · 3 comments

Following the instructions on From ES6 to Scala: Advanced, I do:

val images = dom.document.querySelectorAll("img").asInstanceOf[NodeListOf[HTMLImageElement]]
images.map(_.src)

The second line doesn't compile, and the compiler tells us: value map is not a member of org.scalajs.dom.NodeListOf[org.scalajs.dom.raw.HTMLImageElement]. If I import org.scalajs.dom.ext._, I'd expect my NodeListOf to be "pimped", but apparently PimpedNodeList only applies on NodeList, and not on NodeListOf. You can try this in this scastie.

Am I missing something, or is there something incorrect in the documentation? (Or both!)

@sjrd things named PimpedAnything aren't so idiomatic now. Perhaps EnrichedNodeList etc. 🌞

sjrd commented

I think the current naming convention is NodeListOps.

This was implemented in #458