tyson Posted April 3, 2013 Share Posted April 3, 2013 Hi all, I finally found a fix for a bug that was plaguing me for months on the iPad1. The mysterious 'TypeError: undefined is not a function' Apparently Safari 5 doesn't have a native 'bind' method. This isn't so apparent if you're using a framework. The workaround involves using a shim: https://gist.github.com/jussi-kalliokoski/978329 -Tys Quote Link to comment Share on other sites More sharing options...
rich Posted April 3, 2013 Share Posted April 3, 2013 There are loads of other ways to raise that error too - but that's a handy thing to know all the same Quote Link to comment Share on other sites More sharing options...
tyson Posted April 3, 2013 Author Share Posted April 3, 2013 True. Although this one seemed specific to Safari 5. I grabbed this workaround from the MelonJS project as they had the same problem. Might be more related to using frameworks I guess! Quote Link to comment Share on other sites More sharing options...
Chris Posted April 4, 2013 Share Posted April 4, 2013 Well, the error you described occures if you try to call a property that is not a function. For example: var test = 1;test();> TypeError: number is not a function Simple: "test" is of type number, not of type function. And since the "bind()" method is not defined on a function object on iOS safari (as well as in a lot of other browsers), the property is of type "undefined", hence your error: "TypeError: undefined is not a function". A solid suite of unit tests should help you covering such bugs very easily. Interestingly I never heard of the bind() method at all and also never saw anyone using it Quote Link to comment Share on other sites More sharing options...
tyson Posted April 4, 2013 Author Share Posted April 4, 2013 This was specifically on iOS 5 Safari, where debugging was hell. Yeah not a noob, I've tried *all* types of online debuggers and they didn't pick up anything at all. Didn't happen on Safari 6, where debugging was loads better. Bind was used mostly with keys and the mouse I suspect. Probably also with binding touch to mouse events too. -Tys Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.