Why aren't NodeList / HtmlCollection seqable?

前端 未结 2 963
一个人的身影
一个人的身影 2021-02-02 13:54

As a newcomer to Clojurescript it appears to me that every Clojurescript project will have some snippet of code like this:

(extend-type js/NodeList
  ISeqable
           


        
相关标签:
2条回答
  • 2021-02-02 13:55

    If you are looking for a way to create a sequence from a NodeList there is array-seq function.

    (array-seq (js/document.querySelectorAll "div"))
    
    0 讨论(0)
  • 2021-02-02 13:57

    You have to think that clojurescript is a compiler to javascript as a language, not only browser JavaScript. You can also use it in other platforms like nodejs or with the QT library where NodeList does not exist (because it is part of the Dom api and not the standard language).

    0 讨论(0)
提交回复
热议问题