Submenu properties and methods not available until menu is showing




7 years ago
5 years ago


(Reporter: mozilla, Unassigned)


6 Branch

Firefox Tracking Flags

(Not tracked)




7 years ago
User Agent: Mozilla/5.0 (X11; Linux i686; rv:6.0) Gecko/20100101 Firefox/6.0
Build ID: 20110811165603

Steps to reproduce:

Create a context menu in XUL, which includes an empty submenu.
In the popupshowing handler, populate the submenu with another menu element.
Try to set the label property on the new menu element, and try to use appendItem() to give it some menuitems.

Actual results:

The label is not set using the property, although it is set using setAttribute.
appendItem() crashes to the error console saying appendItem() is not a method.
If the submenu popup is shown, then the next time the context menu is opened everything works.

Expected results:

The properties and methods documented for the menu element should work.
The label property should set the label on the menu.
The appendItem() method should create a new menuitem on the menu.

This behaviour appears to be caused because submenus are explicitly not initialised when their containing menu is initialised.  I believe that the bindings that contain properties such as "label" and methods such as appendItem() do not get bound until the menu frame itself is initialised when it is eventually shown.  This is deliberate and commented in the code, although I'm not sure if the side effects described in this bug are expected.  If this is considered WONTFIX then it should at least be documented that you can't use menu element properties and methods until the menu has been shown.

Comment 1

7 years ago
The same thing occurs if you try to access the properties or methods of a hidden submenu.


5 years ago
Component: General → XUL
Product: Firefox → Core
You need to log in before you can comment on or make changes to this bug.