Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,14 +32,15 @@ Function.implement({ | |
attempt: function(args, bind){ | ||
try { | ||
return this.apply(bind, Array.from(args)); | ||
} catch (e){ | ||
return null; | ||
} | ||
} catch (e){} | ||
|
||
return null; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
cpojer
Author
Member
|
||
}, | ||
|
||
bind: function(bind, args){ | ||
var self = this; | ||
if (args != null) args = Array.from(args); | ||
bind: function(bind){ | ||
var self = this, | ||
args = (arguments.length > 1) ? Array.slice(arguments, 1) : null; | ||
|
||
return function(){ | ||
return self.apply(bind, args || arguments); | ||
}; | ||
|
@@ -50,7 +51,11 @@ Function.implement({ | |
}, | ||
|
||
pass: function(args, bind){ | ||
return this.bind(bind, args); | ||
var self = this; | ||
if (args != null) args = Array.from(args); | ||
return function(){ | ||
return self.apply(bind, args || arguments); | ||
}; | ||
}, | ||
|
||
periodical: function(periodical, bind, args){ | ||
|
@@ -65,8 +70,18 @@ Function.implement({ | |
|
||
//<1.2compat> | ||
|
||
delete Function.prototype.bind; | ||
|
||
Function.implement({ | ||
|
||
bind: function(bind, args){ | ||
var self = this; | ||
if (args != null) args = Array.from(args); | ||
return function(){ | ||
return self.apply(bind, args || arguments); | ||
}; | ||
}, | ||
|
||
create: function(options){ | ||
var self = this; | ||
options = options || {}; | ||
|
2 comments
on commit aa8d931
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In regards to #bind. Since we're now following spec/prototypejs then we should consider this optimization: https://prototype.lighthouseapp.com/projects/8886-prototype/tickets/215
Take a look at the charts, it's a "dramatic" improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind doing the fix and sending a pull request? :)
common makes no difference at all...