Skip to content

Commit 69b6605

Browse files
committed
Fix warn function in IE9
1 parent 07179dc commit 69b6605

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/default.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@
7676

7777
// A simple log function so the user knows why a request is not being send
7878
warn = function () {
79-
if (con && con.warn) {
80-
// 1. Convert args to a normal array
81-
var args = [].slice.call(arguments);
79+
// 1. Convert args to a normal array
80+
var args = [].slice.call(arguments);
8281

83-
// 2. Prepend log prefix
84-
args.unshift("Simple Analytics:");
82+
// 2. Prepend log prefix
83+
args.unshift("Simple Analytics: ");
8584

86-
// 3. Pass along arguments to console.warn
87-
con.warn.apply(con, args);
88-
}
85+
// 3. Pass along arguments to console.warn
86+
// Function.prototype.bind.call is needed for Internet Explorer
87+
var log = Function.prototype.bind.call(con.warn, con);
88+
log.apply(con, args);
8989
};
9090

9191
var warnInFunction = function (name, error) {

0 commit comments

Comments
 (0)