[js] simplify cw.log implementation
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Fri, 25 Jul 2014 16:11:46 +0200
changeset 10407 18d1ef2d2a3e
parent 10406 9c7461bf99a7
child 10408 ec284980ed9e
[js] simplify cw.log implementation There's no need to rebuild and array and join its content, just call console.log with ``arguments``. The only trick is that console.log must be called on a console instance.
web/data/cubicweb.js
--- a/web/data/cubicweb.js	Mon Jun 22 11:28:16 2015 +0200
+++ b/web/data/cubicweb.js	Fri Jul 25 16:11:46 2014 +0200
@@ -15,13 +15,10 @@
     removeEventListener: function() {},
     detachEvent: function() {},
 
-    log: function () {
-        var args = [];
-        for (var i = 0; i < arguments.length; i++) {
-            args.push(arguments[i]);
-        }
+    log: function log() {
         if (typeof(window) != "undefined" && window.console && window.console.log) {
-            window.console.log(args.join(' '));
+            // NOTE console.log requires "console" to be the console to be "this"
+            window.console.log.apply(console, arguments);
         }
     },