On Monday, 30 March 2015, Oliver George <[email protected]
<javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote:

> Hi Guys
>
> Is there a recommended polyfill for working with IE8?
>
> I'm using console-polyfill <https://github.com/paulmillr/console-polyfill>
> but it's not compatible with enable-console-print! because it uses .apply
> which is undefined <http://stackoverflow.com/a/1262103/176453>.
>
> (defn enable-console-print!
>   "Set *print-fn* to console.log"
>   []
>   (set! *print-newline* false)
>   (set! *print-fn*
>     (fn [& args]
>       (.apply (.-log js/console) js/console (into-array args)))))
>
>
> thanks, Oliver
>

The call to apply is there to support multiple arities in calls to Clojure
print functions. I can see three ways around the problem. The first one
would be never to call a print function with more than one argument, in
which case you could just skip the apply call:

  (set! *print-newline* false)
  (set! *print-fn*
    (fn [& args]
      (js/console.log (first args))))

The second one would be to have your own way of turning the args into a
string, which you can then pass to console.log as its only argument. The
third one would be to just pass the array to console.log, essentially just
removing the call to apply. I have no idea how IE8 handles logging an
array, though. Other browsers handle it well.

(I don't know anything about a polyfill for that.)

-- 
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.

Reply via email to