Skip to content

Commit fdd97e5

Browse files
committed
Ensure IE check works in IE < 9
Ok, strictly speaking this isn't too important, as it's been a long time since IE9 came out, but that's what we say we support, it's easy enough to support it here, and one of the big reasons this library exists is to give you reliable logging, everywhere. It's nice to do that *everywhere*, when we can.
1 parent 81bccb5 commit fdd97e5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/loglevel.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
var noop = function() {};
2121
var undefinedType = "undefined";
2222
var isIE = (typeof window !== undefinedType) && (
23-
window.navigator.userAgent.indexOf('Trident/') >= 0 ||
24-
window.navigator.userAgent.indexOf('MSIE ') >= 0
23+
/Trident\/|MSIE /.test(window.navigator.userAgent)
2524
);
2625

2726
var logMethods = [
@@ -51,7 +50,14 @@
5150

5251
// Trace() doesn't print the message in IE, so for that case we need to wrap it
5352
function traceForIE() {
54-
if (console.log) console.log.apply(console, arguments);
53+
if (console.log) {
54+
if (console.log.apply) {
55+
console.log.apply(console, arguments);
56+
} else {
57+
// In old IE, native console methods themselves don't have apply().
58+
Function.prototype.apply.apply(console.log, [console, arguments]);
59+
}
60+
}
5561
if (console.trace) console.trace();
5662
}
5763

0 commit comments

Comments
 (0)