Skip to content

Commit

Permalink
Added function#bind polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Oct 15, 2011
1 parent 8eb92e5 commit 3404e72
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions readabilitySAX/readabilitySAX.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,30 @@
return new F();
};
}
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
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 fSlice = Array.prototype.slice,
aArgs = fSlice.call(arguments, 1),
fToBind = this,
fNOP = function () {},
fBound = function () {
return fToBind.apply(this instanceof fNOP
? this
: oThis || window,
aArgs.concat(fSlice.call(arguments)));
};
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
return fBound;
};
}
y.include("https://raw.github.com/FB55/yql-tables/master/readabilitySAX/E4XasSAX.js");
y.include("https://raw.github.com/FB55/yql-tables/master/readabilitySAX/node_url_module.js");
Expand Down

0 comments on commit 3404e72

Please sign in to comment.