Skip to content

Commit

Permalink
Merge pull request #114 from lupincn/support/1.0.x
Browse files Browse the repository at this point in the history
fixed IE haven't bind function
  • Loading branch information
mikaelkaron committed Aug 7, 2013
2 parents 0c7e1b2 + 7d0679c commit 81278e6
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/logger/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,26 @@
define([ "compose", "../component/base" ], function ConsoleLogger(Compose, Component) {
var CONSOLE = console;

// adapted from Mozilla Developer Network example at
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
var bind = Function.prototype.bind || function (obj) {
var args = slice.call(arguments, 1),
self = this,
nop = function () {},
bound = function () {
return self.apply(this instanceof nop ? this : (obj || {}), args.concat(slice.call(arguments)));
};
nop.prototype = this.prototype || {}; // Firefox cries sometimes if prototype is undefined
bound.prototype = new nop();
return bound;
};

return Compose.create(Component, {
"log" : CONSOLE.log.bind(CONSOLE),
"warn" : CONSOLE.warn.bind(CONSOLE),
"debug" : CONSOLE.debug.bind(CONSOLE),
"info" : CONSOLE.info.bind(CONSOLE),
"error" : CONSOLE.error.bind(CONSOLE)
"log" : bind.call(CONSOLE.log, CONSOLE),
"warn" : bind.call(CONSOLE.warn || CONSOLE.log, CONSOLE),
"debug" : bind.call(CONSOLE.debug || CONSOLE.log, CONSOLE),
"info" : bind.call(CONSOLE.info || CONSOLE.log, CONSOLE),
"error" : bind.call(CONSOLE.error || CONSOLE.log, CONSOLE)
});

});

0 comments on commit 81278e6

Please sign in to comment.