It would be nice to have this as a canned set of functions on the ready, but I think global extend-type stuff should never load with namespace initialization except in your specific app.
On Wed, Oct 8, 2014 at 2:58 PM, Peter Jaros <[email protected]> wrote: > It wouldn’t be appropriate to drop the extend-types into any old library, > but would it be appropriate to have an adapter library *specifically* to > extend browser types with a reasonable set of interfaces? That way, folks > targeting browsers can use that library and get everything they expect in > one go, while keeping it out of core. > > Peter > > > On Wed, Oct 8, 2014 at 2:32 AM, Ravindra Jaju <[email protected]> > wrote: > >> FWIW, I ran into something similar and this SO post helped me understand >> the rationale >> >> >> http://stackoverflow.com/questions/23616019/why-arent-nodelist-htmlcollection-seqable >> >> -- >> jaju >> >> On Tue, Oct 7, 2014 at 9:13 PM, Joel Holdbrooks <[email protected]> >> wrote: >> >>> On Thursday, October 2, 2014 1:37:47 AM UTC-7, Marcus Lewis wrote: >>> > => (doseq [file lastFileList] (.-name file)) >>> > Error: [object FileList] is not ISeqable >>> > at Error (native) >>> > at cljs.core.seq (http://localhost:8080/app.js:3164:67) >>> > >>> > => (doseq [file (array-seq lastFileList)] (.log js/console (.-name >>> file))) >>> > >>> > This works. It logs the filename. In case you're curious, this >>> FileList is coming from drag-drop events) >>> > >>> > Here's the ClojureScript that I would hope would catch this: >>> > (array? coll) >>> > (when-not (zero? (alength coll)) >>> > (IndexedSeq. coll 0)) >>> > >>> > The resulting js is: >>> > if (a instanceof Array || "string" === typeof a) { >>> > return 0 === a.length ? null : new cljs.core.IndexedSeq(a, 0); >>> > } >>> > >>> > Is there any reason not to make other array-like types ISeqable? I'm >>> sure there are better examples than FileList. For example, the same issue >>> can be seen with HTMLCollection: >>> > >>> > => (seq (.getElementsByTagName js/document.body "div")) >>> > Error: [object HTMLCollection] is not ISeqable >>> > at Error (native) >>> > at cljs.core.seq (http://localhost:8080/app.js:3164:67) >>> >>> If you don't want to use extend-type, reify, or specify!, you can use >>> `array-seq`. >>> >>> > (array-seq (js/document.querySelectorAll "span")) >>> (#<[object HTMLSpanElement]> #<[object HTMLSpanElement]> ...) >>> >>> -- >>> Note that posts from new members are moderated - please be patient with >>> your first post. >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "ClojureScript" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at http://groups.google.com/group/clojurescript. >>> >> >> -- >> Note that posts from new members are moderated - please be patient with >> your first post. >> --- >> You received this message because you are subscribed to the Google Groups >> "ClojureScript" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/clojurescript. >> > > > > -- > Visuals: http://youtube.com/peeja > Words: http://blog.peeja.com/ > Conversation: (603) 548-1203 > > -- > Note that posts from new members are moderated - please be patient with > your first post. > --- > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/clojurescript. > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
