From a847aeb941eb0c45036b20b8441183e1e767c6aa Mon Sep 17 00:00:00 2001 From: Gabriel Fouasnon Date: Fri, 15 Jan 2016 14:07:46 -0800 Subject: [PATCH 1/6] Fix broken logDebug() in IE less than v10 --- src/raven.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/raven.js b/src/raven.js index f42b779188e8..ffc71c08414e 100644 --- a/src/raven.js +++ b/src/raven.js @@ -1079,8 +1079,14 @@ Raven.prototype = { }, _logDebug: function(level) { + var args = [].slice.call(arguments, 1); if (this._originalConsoleMethods[level] && this.debug) { - this._originalConsoleMethods[level].apply(this._originalConsole, [].slice.call(arguments, 1)); + try { + // For IE<10, cannot invoke 'apply' on console methods + this._originalConsoleMethods[level].apply(this._originalConsole, args); + } catch (err) { + this._originalConsole[level](args.join(' ')); + } } }, From e9c317e332d23c39c438b1734dd58762636cb7be Mon Sep 17 00:00:00 2001 From: Gabriel Fouasnon Date: Fri, 15 Jan 2016 15:08:02 -0800 Subject: [PATCH 2/6] mimic console.js plugin --- src/raven.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/raven.js b/src/raven.js index ffc71c08414e..27c7e59bee00 100644 --- a/src/raven.js +++ b/src/raven.js @@ -1079,14 +1079,13 @@ Raven.prototype = { }, _logDebug: function(level) { - var args = [].slice.call(arguments, 1); if (this._originalConsoleMethods[level] && this.debug) { - try { - // For IE<10, cannot invoke 'apply' on console methods - this._originalConsoleMethods[level].apply(this._originalConsole, args); - } catch (err) { - this._originalConsole[level](args.join(' ')); - } + // taken from plugis/console.js + // IE9 doesn't allow calling apply on console functions directly + // See: https://stackoverflow.com/questions/5472938/does-ie9-support-console-log-and-is-it-a-real-function#answer-5473193 + Function.prototype.bind + .call(this._originalConsoleMethods[level], this._originalConsole) + .apply(this._originalConsole, [].slice.call(arguments, 1)); } }, From 9c63e368f1f3a7c3769bfedfa323b96d99449257 Mon Sep 17 00:00:00 2001 From: Gabriel Fouasnon Date: Fri, 15 Jan 2016 15:09:13 -0800 Subject: [PATCH 3/6] typo --- src/raven.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/raven.js b/src/raven.js index 27c7e59bee00..7636e67857eb 100644 --- a/src/raven.js +++ b/src/raven.js @@ -1080,7 +1080,7 @@ Raven.prototype = { _logDebug: function(level) { if (this._originalConsoleMethods[level] && this.debug) { - // taken from plugis/console.js + // taken from plugins/console.js // IE9 doesn't allow calling apply on console functions directly // See: https://stackoverflow.com/questions/5472938/does-ie9-support-console-log-and-is-it-a-real-function#answer-5473193 Function.prototype.bind From aad9c7245bc138119fce7a3bbc3d7eb6928be2e9 Mon Sep 17 00:00:00 2001 From: Gabriel Fouasnon Date: Fri, 15 Jan 2016 15:32:40 -0800 Subject: [PATCH 4/6] Revert "typo" This reverts commit 9c63e368f1f3a7c3769bfedfa323b96d99449257. --- src/raven.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/raven.js b/src/raven.js index 7636e67857eb..27c7e59bee00 100644 --- a/src/raven.js +++ b/src/raven.js @@ -1080,7 +1080,7 @@ Raven.prototype = { _logDebug: function(level) { if (this._originalConsoleMethods[level] && this.debug) { - // taken from plugins/console.js + // taken from plugis/console.js // IE9 doesn't allow calling apply on console functions directly // See: https://stackoverflow.com/questions/5472938/does-ie9-support-console-log-and-is-it-a-real-function#answer-5473193 Function.prototype.bind From 8f14ba99c905220047bb3692851fe68470fa2fa0 Mon Sep 17 00:00:00 2001 From: Gabriel Fouasnon Date: Fri, 15 Jan 2016 15:32:47 -0800 Subject: [PATCH 5/6] Revert "mimic console.js plugin" This reverts commit e9c317e332d23c39c438b1734dd58762636cb7be. --- src/raven.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/raven.js b/src/raven.js index 27c7e59bee00..ffc71c08414e 100644 --- a/src/raven.js +++ b/src/raven.js @@ -1079,13 +1079,14 @@ Raven.prototype = { }, _logDebug: function(level) { + var args = [].slice.call(arguments, 1); if (this._originalConsoleMethods[level] && this.debug) { - // taken from plugis/console.js - // IE9 doesn't allow calling apply on console functions directly - // See: https://stackoverflow.com/questions/5472938/does-ie9-support-console-log-and-is-it-a-real-function#answer-5473193 - Function.prototype.bind - .call(this._originalConsoleMethods[level], this._originalConsole) - .apply(this._originalConsole, [].slice.call(arguments, 1)); + try { + // For IE<10, cannot invoke 'apply' on console methods + this._originalConsoleMethods[level].apply(this._originalConsole, args); + } catch (err) { + this._originalConsole[level](args.join(' ')); + } } }, From 36db1b7644fafc10670c5b0cfa43543acef21bc4 Mon Sep 17 00:00:00 2001 From: Gabriel Fouasnon Date: Fri, 15 Jan 2016 15:46:31 -0800 Subject: [PATCH 6/6] use Function.prototype.apply --- src/raven.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/raven.js b/src/raven.js index ffc71c08414e..d010fff84427 100644 --- a/src/raven.js +++ b/src/raven.js @@ -1079,14 +1079,13 @@ Raven.prototype = { }, _logDebug: function(level) { - var args = [].slice.call(arguments, 1); if (this._originalConsoleMethods[level] && this.debug) { - try { - // For IE<10, cannot invoke 'apply' on console methods - this._originalConsoleMethods[level].apply(this._originalConsole, args); - } catch (err) { - this._originalConsole[level](args.join(' ')); - } + // In IE<10 console methods do not have their own 'apply' method + Function.prototype.apply.call( + this._originalConsoleMethods[level], + this._originalConsole, + [].slice.call(arguments, 1) + ); } },