File tree Expand file tree Collapse file tree 1 file changed +18
-12
lines changed Expand file tree Collapse file tree 1 file changed +18
-12
lines changed Original file line number Diff line number Diff line change 11// ES5 Polyfills
22// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
33if ( ! Function . prototype . bind ) {
4- Function . prototype . bind = function bind ( obj ) {
5- var args = slice . call ( arguments , 1 ) ;
6- var self = this ;
7- var F = function ( ) { } ;
8- var bounded = function ( ) {
9- return self . apply (
10- this instanceof F ? this : ( obj || { } ) ,
11- args . concat ( slice . call ( arguments ) )
12- ) ;
4+ Function . prototype . bind = function ( oThis ) {
5+ if ( typeof this !== 'function' ) {
6+ throw new TypeError ( 'Function.prototype.bind - what is trying to be bound is not callable' ) ;
7+ }
8+
9+ var aArgs = Array . prototype . slice . call ( arguments , 1 ) ;
10+ var fToBind = this ;
11+ var NoOp = function ( ) {
12+ } ;
13+ var fBound = function ( ) {
14+ return fToBind . apply ( this instanceof NoOp && oThis ? this : oThis ,
15+ aArgs . concat ( Array . prototype . slice . call ( arguments ) ) ) ;
1316 } ;
14- F . prototype = this . prototype || { } ;
15- bounded . prototype = new F ( ) ;
16- return bounded ;
17+
18+ NoOp . prototype = this . prototype ;
19+ fBound . prototype = new NoOp ( ) ;
20+
21+ return fBound ;
1722 } ;
1823}
1924
25+
2026// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
2127if ( ! Array . prototype . map ) {
2228 Array . prototype . map = function ( callback , thisArg ) {
You can’t perform that action at this time.
0 commit comments