Skip to content

Commit

Permalink
feat(console): moved console fix from logging-console to polyfills
Browse files Browse the repository at this point in the history
  • Loading branch information
doktordirk committed May 18, 2016
1 parent 13114b2 commit 6db2334
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion build/tasks/build.js
Expand Up @@ -21,7 +21,8 @@ gulp.task('build-index', function(){
'array.js',
'object.js',
'collections.js',
'reflect.js'
'reflect.js',
'console.js'
].map(function(file){
return paths.root + file;
});
Expand Down
22 changes: 22 additions & 0 deletions src/console.js
@@ -0,0 +1,22 @@
import {PLATFORM} from 'aurelia-pal';

(function(global) {
global.console = global.console || {};
let con = global.console;
let prop;
let method;
let empty = {};
let dummy = function() {};
let properties = 'memory'.split(',');
let 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;
})(PLATFORM.global);

if (PLATFORM.global.console && typeof console.log === 'object') {
['log', 'info', 'warn', 'error', 'assert', 'dir', 'clear', 'profile', 'profileEnd'].forEach(function(method) {
console[method] = this.bind(console[method], console);
}, Function.prototype.call);
}

0 comments on commit 6db2334

Please sign in to comment.