From a8b157c58de90d93446f6d4a69f861da1003b235 Mon Sep 17 00:00:00 2001 From: Artem Fitiskin Date: Mon, 16 Mar 2015 22:46:16 +0300 Subject: [PATCH] Update console polyfill. Fix #731 --- app/js/lib/polyfill.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/app/js/lib/polyfill.js b/app/js/lib/polyfill.js index 8d28947e..e4b411b0 100644 --- a/app/js/lib/polyfill.js +++ b/app/js/lib/polyfill.js @@ -1,19 +1,23 @@ // Console-polyfill. MIT license. // https://github.com/paulmillr/console-polyfill // Make it safe to do console.log() always. -(function (con) { +(function(global) { 'use strict'; + global.console = global.console || {}; + var con = global.console; var prop, method; var empty = {}; var dummy = function() {}; var properties = 'memory'.split(','); - var methods = ('assert,count,debug,dir,dirxml,error,exception,group,' + - 'groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,' + - 'time,timeEnd,trace,warn').split(','); - while (prop = properties.pop()) con[prop] = con[prop] || empty; - while (method = methods.pop()) con[method] = con[method] || dummy; -})(this.console = this.console || {}); - + var methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,' + + 'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' + + 'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn').split(','); + while (prop = properties.pop()) if (!con[prop]) con[prop] = empty; + while (method = methods.pop()) if (!con[method]) con[method] = dummy; +})(typeof window === 'undefined' ? this : window); +// Using `this` for web workers while maintaining compatibility with browser +// targeted script loaders such as Browserify or Webpack where the only way to +// get to the global object is via `window`. /* Array.indexOf polyfill */ if (!Array.prototype.indexOf) { @@ -77,11 +81,11 @@ if (typeof Object.create != 'function') { if (!Function.prototype.bind) { Function.prototype.bind = function (oThis) { if (typeof this !== "function") { - throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); } - var aArgs = Array.prototype.slice.call(arguments, 1), - fToBind = this, + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, fNOP = function () {}, fBound = function () { return fToBind.apply(this instanceof fNOP && oThis