From d83046460fbacce3007981013b59d753ff6bbd96 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 25 May 2012 18:03:02 +0200 Subject: [PATCH] fix window.console.log for IE8/IE9 --- source/Ox/js/Fallback.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/source/Ox/js/Fallback.js b/source/Ox/js/Fallback.js index efdc0fc4..29d21971 100644 --- a/source/Ox/js/Fallback.js +++ b/source/Ox/js/Fallback.js @@ -275,7 +275,7 @@ Ox.fallback.trim = function() { }; (function() { - var method, object; + var log, method, object; for (method in Ox.fallback) { object = method == 'bind' ? Function.prototype : method == 'isArray' ? Array @@ -286,11 +286,19 @@ Ox.fallback.trim = function() { object[method] = Ox.fallback[method]; } } - // IE9 in developer mode has window.console, but no window.console.log.apply + // IE8 has window.console, but window.console.log is an object, + // IE9 has window.console, but window.console.log has no apply // see http://stackoverflow.com/questions/5472938/does-ie9-support-console-log-and-is-it-a-real-function - if (window.console && !window.console.log.apply) { - window.console.log = Function.prototype.bind.call( - window.console.log, window.console - ); + if (window.console) { + if (typeof window.console.log !== 'function') { + log = window.console.log; + window.console.log = function() { + log(Array.prototype.slice.call(arguments).join(' ')); + } + } else if (!window.console.log.apply) { + window.console.log = Function.prototype.bind.call( + window.console.log, window.console + ); + } } })();