-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Function.prototype.bind is undefined #10522
Comments
kpozin@gmail.com commented:
|
j...@thereitis.com commented:
|
t...@creationix.com commented:
|
t...@creationix.com commented:
|
yanf...@edgespring.com commented:
|
ariya.hi...@gmail.com commented:
|
bradwill...@gmail.com commented:
|
Is there a current workaround for this while we wait for #10031? Simply creating a shim in my phantom runner script using this code from MDN doesn't seem to apply to the |
@tupton When I created a Function.prototype.bind polyfill, it worked fine for me. https://github.com/c9/smith/blob/master/tests/public/test.js#L2-L7 |
@creationix Thanks for that pointer. I'm extremely new to phantomjs and still trying to figure out everything in context. I was trying to define |
This change adds a shim for `Function.prototype.bind()`, which can be an intermediate step until we get the native implementation from a newer WebKit. This fixes ariya#10522.
“Why PhantomJS doesn't have Function.prototype.bind” by @ariya: https://groups.google.com/forum/#!msg/phantomjs/r0hPOmnCUpc/uxusqsl2LNoJ |
My long explanation is posted in https://groups.google.com/forum/#!msg/phantomjs/r0hPOmnCUpc/uxusqsl2LNoJ. The summary: We never intended this to happen. PhantomJS relies on QtWebKit in Qt and the last stable version of Qt (which has updated QtWebKit) was slow to emerge (for a lot of technical and non-technical reasons). We already tried some attempts to rectify the situation. Unfortunately it's a lot of work and all the combined spare-time of our contributors is not enough to bring the solution to the table. |
@ariya, thank you for your hard work, and thanks to the other volunteers. Your efforts are much appreciated. The long explanation helps. With respect to the port to Qt 5, where does that get us exactly? How fresh is its fresher QtWebKit? |
For Qt 5 stuff, please track issue #10448. It's too early to say but what I can confirm is that |
PhantomJS (1.9.1 and below) does not provides the `Function.prototype.bind` method. Since PhantomJS is already used in production in CI environment such TravisCI it may be simpler for source-map to have a shim rather than waiting for PhantomJS to fix that.
Hi, Are there any news on this? This polyfill can handle the issue, but it would be great if we could get a newer JS Core in PHJS:) |
For me polyfill didn't work. But underscore's bind did. |
I have added mentioned shim, but |
In my case I can replace native bind() for Underscore's bind and works properly. |
So that Travis build passes. Also don't use Function.bind because oddly enough PhantomJS still barfs on it, not sure why though: ariya/phantomjs#10522
Work around until we can upgrade to phantomjs 2.0. ariya/phantomjs#10522
Work around until we can upgrade to phantomjs 2.0. ariya/phantomjs#10522
Work around until we can upgrade to phantomjs 2.0. ariya/phantomjs#10522
Extracted from @creationix post. The full solution is here: // PhantomJS doesn't support bind yet
Function.prototype.bind = Function.prototype.bind || function (thisp) {
var fn = this;
return function () {
return fn.apply(thisp, arguments);
};
}; Append this on top of your tests and it will fix the issue. Worked like a charm for me. Thank you! |
@andreaugusto / @creationix: However, there are also a number of shortcomings with this workaround that will prevent from working for everyone's needs:
The first two can be addressed with a better polyfill implementation (Mozilla's MDN one is pretty good). However, the third seems to be elusive despite our having creates various hooks into the page lifecycle(s). |
@andreaugusto, you might wish to use the polyfill from MDN which is more complete, but lists its caveats. |
For me polyfill from MDN didn't work well in all cases, but underscore _.bind did. |
PhantonJS uses an old version of javascript core: ariya/phantomjs#10522
Any chances to see this fixed? PhantomJS seems to be the last browser not to support By the way, if you are using Bower, bind-polyfill by @kdimatteo provides Mozilla's MDN polyfill:
|
@amercier, This issue is fixed in PhantomJS 2 :) |
- fix Function.bind phantomjs issue: ariya/phantomjs#10522 - make tests more stable - fix tests for jquery and vanilla CFY-2106
Converts one simple view to React. Remaining .erb views will be converted in a subsequent commit. Includes a polyfill for `Function.prototype.bind` in Poltergeist/PhantomJS (apparently it will be addressed in PhantomJS v2.0). Source: ariya/phantomjs#10522.
kpozin@gmail.com commented:
Disclaimer:
This issue was migrated on 2013-03-15 from the project's former issue tracker on Google Code, Issue #522.
🌟 24 people had starred this issue at the time of migration.
The text was updated successfully, but these errors were encountered: