Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ember crashes when used along with Prototype.js (or could be any third party js) #9339

Closed
susaiarul opened this issue Oct 16, 2014 · 6 comments

Comments

@susaiarul
Copy link

I am embedding my ember app in another environment where prototype.js is also used. I am getting errors in the console when the ember application is created (Ember.Application.create()). I read the documentation of emberjs about disabling prototype extensions (http://emberjs.com/guides/configuring-ember/disabling-prototype-extensions/ ). I have tried the steps suggested there, but the errors persists as the ember application crashes. Jsbin link http://jsbin.com/raqab/2/edit .Please suggest me a possible solution for this.

Note: This might be a repeated question. Since i am a beginner, it confuses me a lot .

@jasonmit
Copy link
Member

Here is a fiddle working http://jsbin.com/balikequwepu/1/edit

But it does appear to be a bug here where Ember.libraries.each implements its own each function, which collides with Prototype's map function which triggers this.each. It's possible that Prototype no longer has this behavior on its more recent versions.

I will verify in the morning.

@susaiarul
Copy link
Author

@jasonmit I really appreciate your effort, but i am afraid that this kind of issues might occur again. Whenever we get these type of issues, there is a need to put a patch. A better solution would be to avoid prototype.js in this case. I am not sure whether it is the only one third party js that collides with Ember. Is there any way to avoid similar issues without putting a patch ?

@fivetanley
Copy link
Member

Our EnumerableUtils and friends use the Array.prototype.forEach method if it's available. That helper is being used here: https://github.com/emberjs/ember.js/blob/master/packages/ember-metal/lib/libraries.js#L37

I think @jayphelps is rewriting libraries here: #9312, we could have it use a for loop instead in the meantime instead of the helpers. I'm pretty sure that wouldn't break the public API of Libraries.

I think @jdalton and @stefanpenner have been talking about using our polyfills always in these helpers to avoid collisions with native methods, like forEach, contains, etc. #9269

However, I think changing the EnumerableUtils behavior would be a breaking change and one we couldn't make until we were ready to start releasing Ember 2.0. Stef could probably fill in what the plans for all the polyfill/enumerable stuff is, if the core team has talked about it already.

@rwjblue
Copy link
Member

rwjblue commented Oct 17, 2014

This is also fixed if you use a more recent prototype version (tested with 1.7.2 and the JSBin provided works properly).

@susaiarul
Copy link
Author

@rwjblue : Yes, Ember is working fine with latest prototype version. But prototype breaks when it is included before Ember. @fivetanley : Thanks for the updating ongoing work on this. It is really good if we avoid collisions.

@wagenet
Copy link
Member

wagenet commented Nov 1, 2014

Looks like #9312 would fix this? Let me know if I'm mistaken and I'll reopen.

@wagenet wagenet closed this as completed Nov 1, 2014
jayphelps added a commit to jayphelps/ember.js that referenced this issue Nov 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants