Open
Bug 531537
Opened 15 years ago
Updated 2 years ago
menulist.removeAllItems destroys menulist.menupopup instead of removing all items, breaks onmenupopup handler of menulist
Categories
(Core :: XUL, defect)
Core
XUL
Tracking
()
NEW
People
(Reporter: thomas8, Unassigned)
References
(Depends on 1 open bug)
Details
Attachments
(1 file)
2.31 KB,
application/vnd.mozilla.xul+xml
|
Details |
OK folks, here's my first bug against XUL... (thanks to Ben Bucksch who gently pushed me into examining this, although I'm really still learning XUL... ;) menulist.removeAllItems destroys the entire <menupopup> child of the menulist, where it should really only "remove all items" _within_ that menupopup (the children of menupopup). Not only are we destroying all attributes of the original <menupopup...> tag (like id etc.), but also this actually breaks the menulist's onpopupshowing handler, if you call menulist.removeAllItems and then re-append items from within the handler (with the intent of updating/recreating the list of menuitems before it pops up). So the popup doesn't show up :( This is the bad code: function removeAllItems() { this.selectedItem = null; var popup = this.menupopup; if (popup) { this.removeChild(popup) // this is too destructive and breaks the popup } } And this should fix it (I hope): function removeAllItems() { this.selectedItem = null; var itemCount = this.itemCount; for( var i = (itemCount-1); i >= 0; i-- ) this.removeItemAt(i); } Other people have seen this bug as well: http://bugs.code.downthemall.net/trac/changeset/1555 (line 404 :)))
Reporter | ||
Comment 1•14 years ago
|
||
Link to the source code causing this bug: http://mxr.mozilla.org/mozilla-central/source/toolkit/content/widgets/menulist.xml#372
Comment 2•14 years ago
|
||
Thanks a lot, Thomas, for filing the bug and the minimal testcase! I hope somebody will pick it up?
Comment 3•6 years ago
|
||
Moving to Core:XUL per https://bugzilla.mozilla.org/show_bug.cgi?id=1455336
Component: XP Toolkit/Widgets: XUL → XUL
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•