Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Replace $.each with Array.prototype.forEach. #1287

Closed
wants to merge 2 commits into from

Conversation

RaymondLim
Copy link
Contributor

This fixes issue #1098

@ghost ghost assigned peterflynn Jul 20, 2012
@@ -156,7 +156,7 @@ define(function (require, exports, module) {
this.clearList();
var self = this;
var count = 0;
$.each(this.displayList, function (index, item) {
this.displayList.froEach(function (item) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: froEach -> forEach

@peterflynn
Copy link
Member

We seem inconsistent about iterating jQuery objects, which are array-like but not plain vanilla arrays.

  • In CodeHintManager we used to use $.each(), but this patch changes it to .forEach()
  • In InlineTextEditor we still use $.each()
  • In WorkingSetView & ProjectManager we use .each()
    (note the distinction: $.each() takes the jQ object as an argument, while .each() is a method on the jQ object).

@rwldrn, what's the best convention here in your opinion? My assumption would be: .forEach() for "true" arrays, .each() for jQuery objects, and $.each() only for objects/maps. Does that sound right?

@peterflynn
Copy link
Member

One other note: we also have a few places where $.each() is used to iterate objects/maps, but the inner function misleadingly names its first argument "index," which suggests it's iterating an array when it's not. SpecRunnerUtils and BootstrapReporter both have this problem.

@peterflynn
Copy link
Member

p.s. if these are too many changes to sneak in on the last day of the sprint, I think it's fine to push this out to sprint 12. Better to wait a couple more days and get everything fully cleaned up IMHO.

@RaymondLim
Copy link
Contributor Author

@peterflynn, I'll push this out to sprint 12 so that we can wait for @rwldrn opinion and do extra cleanup that you pointed out.

@rwaldron
Copy link

I'm flattered 😊 that you thought of me

@pthiess
Copy link
Contributor

pthiess commented Jul 21, 2012

:) @rwldrn Rick, don't miss the opportunity to share your opinion.

@peterflynn
Copy link
Member

@rwldrn, well you did file the original bug in this case... :-)

@RaymondLim
Copy link
Contributor Author

Closing this pull request since we need to do other cleaning that Peter mentioned.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants