Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Add Function.prototype.bind polyfill see #7951 #7956

Merged
merged 3 commits into from
May 28, 2014
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ module.exports = function (grunt) {
specs : '<%= meta.specs %>',
/* Keep in sync with test/SpecRunner.html dependencies */
vendor : [
'test/polyfills.js',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WebsiteDeveloper, perhaps it makes sense to mention the issue #7951 in a comment here and that it should not be required once we update to a PhantomJS with not-so-outdated JS engine.

'src/thirdparty/jquery-2.1.0.min.js',
'src/thirdparty/CodeMirror2/lib/codemirror.js',
'src/thirdparty/CodeMirror2/lib/util/dialog.js',
Expand Down
25 changes: 25 additions & 0 deletions test/polyfills.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(function () {
"use strict";

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 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;
};
}
}());