Skip to content
This repository has been archived by the owner on Apr 18, 2018. It is now read-only.

Add a polyfill for Function.prototype.bind #113

Merged
merged 1 commit into from
Jan 23, 2015
Merged

Add a polyfill for Function.prototype.bind #113

merged 1 commit into from
Jan 23, 2015

Conversation

rzane
Copy link
Contributor

@rzane rzane commented Jan 23, 2015

Function.prototype.bind isn't supported by all browsers. This PR just adds the polyfill mentioned here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind.

Alternatively, you could just not use bind and go with traditional this/that.

I personally use Poltergeist (which doesn't support Function.prototype.bind) as my javascript driver for Capybara and every test fails like this:

Capybara::Poltergeist::JavascriptError:
       One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).

       TypeError: 'undefined' is not a function (evaluating 'this.modal.find.bind(this.modal)')
       TypeError: 'undefined' is not a function (evaluating 'this.modal.find.bind(this.modal)')
           at http://127.0.0.1:37970/assets/application.js:23283
           at http://127.0.0.1:37970/assets/application.js:23693
           at http://127.0.0.1:37970/assets/application.js:375
           at http://127.0.0.1:37970/assets/application.js:140
           at http://127.0.0.1:37970/assets/application.js:23705
           at http://127.0.0.1:37970/assets/application.js:23710
           at http://127.0.0.1:37970/assets/application.js:3095
           at http://127.0.0.1:37970/assets/application.js:3207
           at http://127.0.0.1:37970/assets/application.js:3413
           at http://127.0.0.1:37970/assets/application.js:3429 in completed

@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.82% when pulling 407197d on rzane:polyfill-for-bind into 5b3bbc8 on volmer:master.

volmer added a commit that referenced this pull request Jan 23, 2015
Add a polyfill for Function.prototype.bind
@volmer volmer merged commit dea651d into volmer:master Jan 23, 2015
@volmer
Copy link
Owner

volmer commented Jan 23, 2015

This is a good improvement. Thank you again for the contribution!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants