Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(console): moved console fix from logging-console to polyfills
- Loading branch information
1 parent
13114b2
commit 6db2334
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |