cujojs / wire

A light, fast, flexible Javascript IOC container

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WireJS cannot run under PhantomJS!

ouadi opened this issue · comments

Dears,

PhantomJS doesn't implement 'Function.prototype.bind' yet. As such, WireJS fails to load under this headless browser (see http://stackoverflow.com/questions/19451808/running-a-requirejs-wirejs-app-using-phantomjs).

I have already mentioned to PhantomJS people this limitation (https://groups.google.com/forum/#!topic/phantomjs/xlGHp3Ycme4).

While waiting an outcome from them, is there a chance to put in place a workaround?

Cheers

Nice find, @ouadi. Have you tried using cujoJS poly to polyfill the ES5 env in phantomJS? I'm betting that would work. I agree that it'd sure be nice if phantom implemented F.p.bind in the near future :)

Let me know if poly works for you.

I suspect poly won't fix this in PhantomJS (but haven't tried it). I suspect that PhantomJS supports Function.prototype.bind, but doesn't support Function.prototype.call.bind. poly/function only checks for existence of Function.prototype.bind since in true js environments, Function.prototype.call is of type Function.

Ack, that's true. If call's prototype is not Function.prototype, then Function.prototype.call.bind wouldn't exist even if Function.prototype.bind does. However (Luckily???), it looks like F.p.bind simply isn't implemented:

phantomjs> Function.prototype.bind
undefined

I'll make some time today to try poly to see if it helps.

Dears,

Sorry for the delay.

The CujoJS/PolyJS has solved my issue. Now, PhantomJS is happy with WireJS thanks to CujoJS/PolyJS. Well, thanks to you guys.

I will update the Stackoverflow and PhantomJS posts.

Cheers.

Hey @ouadi, I'll update the SO post. I was meaning to anyways. Thanks for trying poly.js! :) -- John

Ok, I did a quick test of using poly (via curl) to polyfill Function.prototype.bind and check to make sure that Function.prototype.call.bind works in the way that wire.js expects. That all seemed to work.

Here's a gist of my test. Please have a look and let me know if it looks like I got it right :)

Haha, looks like we all converged on the solution at the same time :) Thanks @ouadi!

Yes, indeed. And you cannot image what a pain you have took away from me.
Thank you to you Brian.

On Tue, Oct 22, 2013 at 3:05 PM, Brian Cavalier notifications@github.comwrote:

Haha, looks like we all converged on the solution at the same time :)
Thanks @ouadi https://github.com/ouadi!


Reply to this email directly or view it on GitHubhttps://github.com//issues/138#issuecomment-26811098
.