fix window.console.log for IE8/IE9

This commit is contained in:
rolux 2012-05-25 18:03:02 +02:00
parent 20564c7fab
commit d83046460f

View file

@ -275,7 +275,7 @@ Ox.fallback.trim = function() {
}; };
(function() { (function() {
var method, object; var log, method, object;
for (method in Ox.fallback) { for (method in Ox.fallback) {
object = method == 'bind' ? Function.prototype object = method == 'bind' ? Function.prototype
: method == 'isArray' ? Array : method == 'isArray' ? Array
@ -286,11 +286,19 @@ Ox.fallback.trim = function() {
object[method] = Ox.fallback[method]; 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 // see http://stackoverflow.com/questions/5472938/does-ie9-support-console-log-and-is-it-a-real-function
if (window.console && !window.console.log.apply) { if (window.console) {
window.console.log = Function.prototype.bind.call( if (typeof window.console.log !== 'function') {
window.console.log, window.console 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
);
}
} }
})(); })();