Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
ee7cae00
...
ee7cae00a9844f9768a756ac6fe8b002035bf580
authored
2013-09-17 10:10:44 -0700
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixes #631 - better .bind() polyfill
1 parent
b7f76a21
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
bin/bootstrap.js
bin/bootstrap.js
View file @
ee7cae0
...
...
@@ -44,12 +44,24 @@ if (!('phantom' in this)) {
// Common polyfills
if
(
typeof
Function
.
prototype
.
bind
!==
"function"
)
{
Function
.
prototype
.
bind
=
function
(
scope
)
{
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Compatibility
Function
.
prototype
.
bind
=
function
(
oThis
)
{
"use strict"
;
var
_function
=
this
;
return
function
()
{
return
_function
.
apply
(
scope
,
arguments
);
/* jshint -W055 */
if
(
typeof
this
!==
"function"
)
{
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw
new
TypeError
(
"Function.prototype.bind - what is trying to be bound is not callable"
);
}
var
aArgs
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
),
fToBind
=
this
,
fNOP
=
function
()
{},
fBound
=
function
()
{
return
fToBind
.
apply
(
this
instanceof
fNOP
&&
oThis
?
this
:
oThis
,
aArgs
.
concat
(
Array
.
prototype
.
slice
.
call
(
arguments
)));
};
fNOP
.
prototype
=
this
.
prototype
;
fBound
.
prototype
=
new
fNOP
();
return
fBound
;
};
}
...
...
Please
register
or
sign in
to post a comment