Closed Bug 1293005 Opened 9 years ago Closed 8 years ago

Replace in-tree consumer of non-standard Iterator() with Object.{values,entries} in im/ in comm-central

Categories

(Instantbird Graveyard :: Other, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Instantbird 53

People

(Reporter: arai, Assigned: dwivedi.aman96, Mentored)

References

Details

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

Attachments

(1 file, 2 obsolete files)

separated from bug 1290637. see bug 1290637 for the details. Required code changes are following: * Check each usage of non-standard Iterator [1] function, and replace it with Object.entries [2] or Object.values [3], or something appropriate for the specific usage Here's the rough list for Iterator() usage (not exhaustive) https://dxr.mozilla.org/comm-central/search?q=%22+Iterator(%22+path%3Aim%2Fcontent&redirect=false for example: for (let [k, v] in Iterator(obj)) { ... } can be replaced to: for (let [k, v] of Object.entries(obj)) { ... } another example: for (let [, v] in Iterator(array)) { ... } can be replaced to: for (let v of array) { ... } [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator [2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries [3] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values
Mentor: arai.unmht
Keywords: good-first-bug
Whiteboard: [good first bug] [lang=js]
Hi Tooru! I would like to take this up. Please assign it to me.
Flags: needinfo?(arai.unmht)
Thank you for your comment :)
Assignee: nobody → dwivedi.aman96
Status: NEW → ASSIGNED
Flags: needinfo?(arai.unmht)
Attached patch bugfix.patch (obsolete) — Splinter Review
I hope this patch works. :)
Attachment #8823222 - Flags: review?(arai.unmht)
Comment on attachment 8823222 [details] [diff] [review] bugfix.patch Review of attachment 8823222 [details] [diff] [review]: ----------------------------------------------------------------- Thank you for your patch :) It looks almost good. Please address the following comment and post updated patch. ::: im/content/jsTreeView.js @@ +124,4 @@ > // for the next add item at our own level. > let currentCount = this._rowMap.length; > if (aChild.children.length && aChild.open) { > + for (let [i, child] of Object.entries(this._rowMap[aNewIndex].children)) { If you use Object.entries, `i` becomes a string and the following expression `aNewIndex + i + 1` becomes string concatenation, instead of numeric operation. Since `this._rowMap[aNewIndex].children` is HTMLCollection, you can convert it to an array with Array.from, and then you can use use Array.prototype.entries instead, so, `Array.from(this._rowMap[aNewIndex].children).entries()` https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/entries
Attachment #8823222 - Flags: review?(arai.unmht) → feedback+
Attached patch BugFix1293005.patch (obsolete) — Splinter Review
Thanks for help :)
Attachment #8823227 - Flags: review?(arai.unmht)
Comment on attachment 8823227 [details] [diff] [review] BugFix1293005.patch Review of attachment 8823227 [details] [diff] [review]: ----------------------------------------------------------------- Thanks again :) ::: im/content/jsTreeView.js @@ +124,4 @@ > // for the next add item at our own level. > let currentCount = this._rowMap.length; > if (aChild.children.length && aChild.open) { > + for (let [i, child] of Object.entries(Array.from(this._rowMap[aNewIndex].children).entries())) { You don't need Object.entries, Array.prototype.entries returns iterator
Attachment #8823227 - Flags: review?(arai.unmht) → feedback+
Oh thanks! Well this should work then. :)
Attachment #8823222 - Attachment is obsolete: true
Attachment #8823227 - Attachment is obsolete: true
Attachment #8823228 - Flags: review?(arai.unmht)
Comment on attachment 8823228 [details] [diff] [review] BugFix1293005.patch Review of attachment 8823228 [details] [diff] [review]: ----------------------------------------------------------------- Thanks! forwarding review to aleth.
Attachment #8823228 - Flags: review?(arai.unmht)
Attachment #8823228 - Flags: review?(aleth)
Attachment #8823228 - Flags: feedback+
Comment on attachment 8823228 [details] [diff] [review] BugFix1293005.patch Review of attachment 8823228 [details] [diff] [review]: ----------------------------------------------------------------- Thanks! ::: im/content/jsTreeView.js @@ -124,4 @@ > // for the next add item at our own level. > let currentCount = this._rowMap.length; > if (aChild.children.length && aChild.open) { > - for (let [i, child] in Iterator(this._rowMap[aNewIndex].children)) { Please check the forked file mailnews/base/content/jsTreeView.js gets matching changes (in another bug).
Attachment #8823228 - Flags: review?(aleth) → review+
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Instantbird 53
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: