From: Dan Vanderkam Date: Sun, 29 Mar 2015 21:12:27 +0000 (-0400) Subject: update console polyfill to v0.2.1 X-Git-Tag: v2.0.0~65 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=9d79fed952e57cd7cd675a2eb30fdf2ce2665cdc;p=dygraphs.git update console polyfill to v0.2.1 --- diff --git a/src/polyfills/console.js b/src/polyfills/console.js index 4a6f542..589a839 100644 --- a/src/polyfills/console.js +++ b/src/polyfills/console.js @@ -1,8 +1,10 @@ // 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() {}; @@ -10,6 +12,9 @@ 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()) con[prop] = con[prop] || empty; - while (method = methods.pop()) con[method] = con[method] || dummy; -})(this.console = this.console || {}); // Using `this` for web workers. + 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`.