From 873dc2e5500d588f0270a7b8cdf0f0dc7e1a2900 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 25 May 2012 18:33:12 +0200 Subject: [PATCH] use global, not window --- source/Ox/js/Fallback.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/source/Ox/js/Fallback.js b/source/Ox/js/Fallback.js index 29d21971..86ea5cb9 100644 --- a/source/Ox/js/Fallback.js +++ b/source/Ox/js/Fallback.js @@ -274,7 +274,7 @@ Ox.fallback.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }; -(function() { +(function(global) { var log, method, object; for (method in Ox.fallback) { object = method == 'bind' ? Function.prototype @@ -286,19 +286,19 @@ Ox.fallback.trim = function() { object[method] = Ox.fallback[method]; } } - // IE8 has window.console, but window.console.log is an object, - // IE9 has window.console, but window.console.log has no apply + // In IE8, window.console.log is an object, + // in IE9, window.console.log.apply is undefined // see http://stackoverflow.com/questions/5472938/does-ie9-support-console-log-and-is-it-a-real-function - if (window.console) { - if (typeof window.console.log !== 'function') { - log = window.console.log; - window.console.log = function() { + if (global.console) { + if (typeof global.console.log !== 'function') { + log = global.console.log; + global.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 + } else if (!global.console.log.apply) { + global.console.log = Function.prototype.bind.call( + global.console.log, global.console ); } } -})(); +})(this);