Closed
Bug 553539
Opened 14 years ago
Closed 14 years ago
Provide a helper function for common toolbar iteration pattern
Categories
(Toolkit :: Toolbars and Toolbar Customization, enhancement)
Toolkit
Toolbars and Toolbar Customization
Tracking
()
RESOLVED
FIXED
mozilla1.9.3a4
People
(Reporter: dao, Assigned: dao)
Details
Attachments
(1 file, 1 obsolete file)
7.73 KB,
patch
|
neil
:
review+
|
Details | Diff | Splinter Review |
Note that I'm using Array.slice(...).forEach( instead of Array.forEach(... so that toolbars can be removed in the callback.
Attachment #433526 -
Flags: review?(neil)
Comment 1•14 years ago
|
||
+ for (let i = 0; i < toolbar.childNodes.length; ++i) { can we use childElementCount here? + let item = toolbar.childNodes[i]; will this work? toolbar.children[i] + if (item.firstChild && item.firstChild.localName == "menubar") firstElementChild? +function forEachToolbar(cb) { + Array.slice(gToolbox.childNodes).forEach(function (toolbar) { + if (isCustomizableToolbar(toolbar)) + cb(toolbar); + }); +} How about? Array.slice(gToolbox.childNodes).filter(isCustomizableToolbar).forEach(cb);
Comment 2•14 years ago
|
||
+function forEachToolbar(cb) { s/cb/callback/g ?
Assignee | ||
Comment 3•14 years ago
|
||
Why would toolbar.children be better than toolbar.childNodes and firstElementChild better than firstChild? This isn't HTML.
Comment 4•14 years ago
|
||
(In reply to comment #1) > How about? > Array.slice(gToolbox.childNodes).filter(isCustomizableToolbar).forEach(cb); Surely if you filter them you don't need to slice first.
Assignee | ||
Comment 5•14 years ago
|
||
using filter
Attachment #433526 -
Attachment is obsolete: true
Attachment #433543 -
Flags: review?(neil)
Attachment #433526 -
Flags: review?(neil)
Comment 6•14 years ago
|
||
Comment on attachment 433543 [details] [diff] [review] patch v2 >+function forEachToolbar(callback) { [Is it too obvious to call this forEachCustomizableToolbar?]
Attachment #433543 -
Flags: review?(neil) → review+
Assignee | ||
Comment 7•14 years ago
|
||
I mused about this as well. It's a bit long, but I guess it's still the better name.
Assignee | ||
Comment 8•14 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/15e4e239321a
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a4
You need to log in
before you can comment on or make changes to this bug.
Description
•