Skip to content

Commit 96ffd38

Browse files
committed
fix($log): should work in IE8
In IE8, reading `console.log.apply` throws an error. Catching this errow now. Fixes angular#5400. Fixes angular#5147.
1 parent 405c8b3 commit 96ffd38

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/ng/log.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,16 @@ function $LogProvider(){
139139

140140
function consoleLog(type) {
141141
var console = $window.console || {},
142-
logFn = console[type] || console.log || noop;
142+
logFn = console[type] || console.log || noop,
143+
hasApply = false;
143144

144-
if (logFn.apply) {
145+
// Note: reading logFn.apply throws an error in IE11 in IE8 document mode.
146+
// The reason behind this is that console.log has type "object" in IE8...
147+
try {
148+
hasApply = !! logFn.apply;
149+
} catch (e) {}
150+
151+
if (hasApply) {
145152
return function() {
146153
var args = [];
147154
forEach(arguments, function(arg) {

0 commit comments

Comments
 (0)