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

Fixing 'maximum call stack size exceeded' errors #260

Merged
merged 4 commits into from
Jan 23, 2015

Conversation

nuragic
Copy link
Contributor

@nuragic nuragic commented Jan 16, 2015

Hi,

I made some changes that solves the following issues:
#180
#210
#224
#233

Basically, I replaced underscore with lodash because it provides a single method called isPlainObject(), that is very helpful in this context.

What do you think?

Thanks!

@nuragic nuragic changed the title Fixing 'maximum call stack sixe exceeded' errors Fixing 'maximum call stack size exceeded' errors Jan 16, 2015
@chiefGui
Copy link
Collaborator

I think your solution is cool, but changing the whole library? Audacious.

Anyway, all the tests passed?

@blikblum
Copy link
Contributor

-1 to add dependency on lodash

@nuragic
Copy link
Contributor Author

nuragic commented Jan 16, 2015

Thank you @chiefGui ! Yep, all the tests passed without change any line of it... Audacious? Why? Lodash is basically the same thing as underscore, but is better... :)

@blikblum Please, can you argue your rejection? Note that I've not just added one dependency more, but I replaced it.

Detailed info about the differences between lodash and underscore here:
http://stackoverflow.com/questions/13789618/differences-between-lodash-and-underscore

@blikblum
Copy link
Contributor

All projects that depends on backbone.validation will be forced to use lodash.
Now, the dev is free to choose between underscore and lodash.

@chiefGui
Copy link
Collaborator

@blikblum is right, all projects dependent of Backbone.Validation will also be dependent of lodash for the front-end, which means another library — very similar to underscore — to be loaded and this way increasing the final weight of the files distributed to our clients.

Lodash is basically the same thing as underscore, but is better... :)

Basically, yes, but say that it is better I think it's too much. I mean, I know it has its strong points, but it also has some weak points which Underscore don't.

Anyway, I need more opinions to merge this. But people, please, argue about.

@nuragic
Copy link
Contributor Author

nuragic commented Jan 18, 2015

Mmmh ok, so, the alternative is to borrow _.isPlainObject(). Sounds better? :) Underscore allows you to extend it with your own custom functions through the _.mixin() method...

@blikblum
Copy link
Contributor

@nuragic borrow _.isPlainObject() or improve flatten.
Can you post an working example that crashes, so i can take a look?

@blikblum
Copy link
Contributor

I used $.isPlainObject and worked fine. Tested against a jquery selector, a model, a date

@nuragic
Copy link
Contributor Author

nuragic commented Jan 19, 2015

@blikblum I've noticed the same thing... Jquery has the isPlainObject method so... I will revert the lodash switch and commit that change very soon! 👍

@chiefGui
Copy link
Collaborator

Awesome! Waiting for you! 👍

@nuragic
Copy link
Contributor Author

nuragic commented Jan 20, 2015

After trying to add jquery as dependency I realized that it was a terrible mess because it requires a document object to work properly in NodeJS. I finally replaced the isPlainObject() method for:

!!val && typeof val === 'object' && val.constructor === Object

(kindly borrowed from https://github.com/jonschlinkert/is-plain-object/blob/master/index.js)

Seems that works like a charm! 🎉 😄

@blikblum
Copy link
Contributor

Looks good to me

@chiefGui
Copy link
Collaborator

Awesome, @nuragic. Could you pull it as 0.9.2?

@nuragic
Copy link
Contributor Author

nuragic commented Jan 20, 2015

@chiefGui Yep, no problem. I have to modify only the package.json or even the README.md?

@chiefGui
Copy link
Collaborator

  • package.json
  • bower.json
  • README.md

and also create a new tag on your branch then squash/pull it.

@nuragic
Copy link
Contributor Author

nuragic commented Jan 21, 2015

bower.json ❓ 😄 I can't see that... It would be nice to have anyway!

@chiefGui
Copy link
Collaborator

Wow, man, my bad. I thought I accepted #251, but I don't. Nevermind, I'm merging your PR.

Thank you man! 👍 💯

@nuragic
Copy link
Contributor Author

nuragic commented Jan 21, 2015

No worries! Thanks to you guys for the awesome work!

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

Successfully merging this pull request may close these issues.

3 participants