Open Bug 1075883 Opened 10 years ago Updated 2 years ago

Populate and teardown listbox and menulist elements in account manager using XUL methods, not direct DOM manipulation

Categories

(MailNews Core :: Account Manager, defect)

defect

Tracking

(Not tracked)

ASSIGNED

People

(Reporter: aceman, Assigned: aceman)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

+++ This bug was initially created as a clone of Bug #1045791 comment 6 +++

:aceman 2014-08-11 14:32:02 CEST

9In some of the account manager menulists,) we clear the items using DOM commands on the menupopup and then add new elements (repopulate the list of servers) using .appendItem method of the XUL element of the parent menulist. That could create confusion for the widget.

Sometimes we even clear children of the menulist (even though there is a menupopup under it and above the menuitems), sometimes we clear the children of the menupopup directly. I think this inconsistency should be cleaned up. Maybe it does not create problems today, but it could in the future.
Product: Thunderbird → MailNews Core
Version: 31 → Trunk
Attached patch patchSplinter Review
Attachment #8498383 - Flags: review?(neil)
Blocks: 1045791
Comment on attachment 8498383 [details] [diff] [review]
patch

> function buildServerFilterMenuList()
> {
>   const KEY_ISP_DIRECTORY_LIST = "ISPDL";
>   let ispHeaderList = document.getElementById("useServerFilterList");
>   // Ensure the menulist is empty.
>-  while (ispHeaderList.hasChildNodes()) {
>-    ispHeaderList.lastChild.remove();
>-  }
>+  ispHeaderList.removeAllItems();
This change is OK but I don't like the others, unless you can get a removeAllItems API added to listboxes.
Attachment #8498383 - Flags: review?(neil) → review-
Why? Is the idea incorrect?
See e.g. radio.xml in toolkit. It maintains an internal list of its <radio> children. Would it work correctly if we started to remove its child nodes via DOM commands? I want to avoid such potential problems in the future.

Also, in some of the cases we do not want a removeAllItems method as we do not remove all items.
(In reply to :aceman from comment #4)
> See e.g. radio.xml in toolkit. It maintains an internal list of its <radio>
> children. Would it work correctly if we started to remove its child nodes
> via DOM commands? I want to avoid such potential problems in the future.
> 
> Also, in some of the cases we do not want a removeAllItems method as we do
> not remove all items.
Flags: needinfo?(neil)
Comment on attachment 8498383 [details] [diff] [review]
patch

Squib, what do you think of this?
Attachment #8498383 - Flags: review?(squibblyflabbetydoo)
Flags: needinfo?(neil)
Comment on attachment 8498383 [details] [diff] [review]
patch

Review of attachment 8498383 [details] [diff] [review]:
-----------------------------------------------------------------

Clearing review here, since I've forgotten most of what I know about the TB codebase and wouldn't be able to give a proper review. Sorry about that... :(
Attachment #8498383 - Flags: review?(jporter+bmo)
Severity: trivial → S4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: