js: Add console polyfill
This commit is contained in:
parent
e51fbd19fd
commit
b62d4d5374
27
js/lib/console-polyfill.js
Normal file
27
js/lib/console-polyfill.js
Normal file
@ -0,0 +1,27 @@
|
||||
/*jslint browser: true, plusplus: true */
|
||||
|
||||
/**
|
||||
* From
|
||||
* http://skratchdot.com/2012/05/prevent-console-calls-from-throwing-errors/
|
||||
*/
|
||||
|
||||
(function (window) {
|
||||
'use strict';
|
||||
|
||||
var i = 0,
|
||||
emptyFunction = function () {},
|
||||
functionNames = [
|
||||
'assert', 'clear', 'count', 'debug', 'dir',
|
||||
'dirxml', 'error', 'exception', 'group', 'groupCollapsed',
|
||||
'groupEnd', 'info', 'log', 'profile', 'profileEnd', 'table',
|
||||
'time', 'timeEnd', 'timeStamp', 'trace', 'warn'
|
||||
];
|
||||
|
||||
// Make sure window.console exists
|
||||
window.console = window.console || {};
|
||||
|
||||
// Make sure all functions exist
|
||||
for (i = 0; i < functionNames.length; i++) {
|
||||
window.console[functionNames[i]] = window.console[functionNames[i]] || emptyFunction;
|
||||
}
|
||||
}(window));
|
||||
Loading…
Reference in New Issue
Block a user