Closed Bug 1125498 Opened 11 years ago Closed 11 years ago

Use for..of iteration instead of Array.forEach in browser-gestureSupport.js

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 38

People

(Reporter: dao, Assigned: babhishek21, Mentored)

Details

(Whiteboard: [good first bug][lang=js])

Attachments

(1 file, 2 obsolete files)

Look for "forEach" (without quotes) in browser/base/content/browser-gestureSupport.js. There should be two matches that can be simplified as follows... instead of: x.forEach(function (y) { ...; }); or: x.forEach(function (y) ..., this); we can do: for (let y of x) { ...; }
On it.
Attached patch bug_1125498: Initial Patch. (obsolete) — Splinter Review
So fixed two occurrences. Heading over to bug 1125497
Attachment #8554177 - Flags: review?(dao)
Comment on attachment 8554177 [details] [diff] [review] bug_1125498: Initial Patch. >- gestureEvents.forEach(function (event) addRemove("Moz" + event, this, true), >- this); >+ for(let event of gestureEvents) { >+ addRemove("Moz" + event, this, true); >+ } Please use spaces instead of tabs and put a space between 'for' and '('. >- ["shift", "alt", "ctrl", "meta"].forEach(function (key) { >- if (aEvent[key + "Key"]) >- keyCombos.push(key); >- }); >+ let pressedKeys = ["shift", "alt", "ctrl", "meta"]; >+ for(let key of pressedKeys) { >+ if (aEvent[key + "Key"]) >+ keyCombos.push(key); >+ } Same here. Also, no need to introduce a variable, the array literal can go right into the for-loop head.
Attachment #8554177 - Flags: review?(dao)
Rev_1: Better style. BTW, can you please assign this bug to me.
Attachment #8554177 - Attachment is obsolete: true
Attachment #8554269 - Flags: review?(dao)
Comment on attachment 8554269 [details] [diff] [review] bug_1125498: rev_1 (Better code style) There are still tabs in here, please use spaces instead.
Attachment #8554269 - Flags: review?(dao)
Assignee: nobody → babhishek21
So I have tried fixing astray TABS/spaces. However my text-editor (Sublime Text) "reflows" indents for visual fidelity. So sometimes two-space indents and four-space indents look the same. I have tried on my part. If you find additional problems, do tell.
Attachment #8554269 - Attachment is obsolete: true
Attachment #8555972 - Flags: review?(dao)
Comment on attachment 8555972 [details] [diff] [review] bug_1125498: rev_2 (Fixed TABS/spaces) >- ["shift", "alt", "ctrl", "meta"].forEach(function (key) { >+ for (let key of ["shift", "alt", "ctrl", "meta"]) { > if (aEvent[key + "Key"]) >- keyCombos.push(key); >- }); >+ keyCombos.push(key); >+ } keyCombos.push(key); should be indented further like it was originally. Everything else looks good now!
Attachment #8555972 - Flags: review?(dao)
Comment on attachment 8555972 [details] [diff] [review] bug_1125498: rev_2 (Fixed TABS/spaces) Landed with comment 7 addressed: https://hg.mozilla.org/integration/fx-team/rev/d4f795acf79c
Attachment #8555972 - Flags: review+
(In reply to Dão Gottwald [:dao] (unavailable in February) from comment #8) > Comment on attachment 8555972 [details] [diff] [review] > bug_1125498: rev_2 (Fixed TABS/spaces) > > Landed with comment 7 addressed: > > https://hg.mozilla.org/integration/fx-team/rev/d4f795acf79c Thanks!
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 38
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: