// removeItemAt fires 'select' event event if 'suppressonselect' // attribute is specified, we shouldn't listen the event (bug 312149) this.suppress = true; for (var i = this.control.childNodes.length-1; i >= 0; i--) { this.control.removeItemAt(i); } this.suppress = false; false var item = this.ownerDocument.createElementNS(this.XUL_NS, "listitem"); item.setAttribute("value", aValue); if (aLabel) { // since label node can contains textnodes then we use // 'description' element as container for label node. var description = this.ownerDocument. createElementNS(this.XUL_NS, "description"); description.appendChild(aLabel.cloneNode(true)); item.appendChild(description); } // XXX: Group supporting isn't implemented this.control.appendChild(item); return item; // XXX: Group supporting isn't implemented return null; // there are cases when 'listitem' binding isn't created yet, // therefore we use setTimeout window.setTimeout( function(list, item) { list.setAttribute("suppressonselect", "true"); list.addItemToSelection(item); list.removeAttribute("suppressonselect"); }, 0, this.control, aItem ); this.control.setAttribute("suppressonselect", "true"); this.control.removeItemFromSelection(aItem); this.control.removeAttribute("suppressonselect"); return aItem.selected; // 'select' event is not always handled when handler is added by using // xbl:handler element. var selectHandler = { control: this, handleEvent: function() { if (!this.control.suppress) { this.control.updateInstanceData(true); } } }; this.addEventListener("select", selectHandler, false); this.dispatchDOMUIEvent("DOMFocusIn"); this.updateInstanceData(false); this.dispatchDOMUIEvent("DOMFocusOut"); var popup = this.control.menupopup; while (popup.hasChildNodes()) { popup.removeChild(popup.lastChild); } var item = this.ownerDocument.createElementNS(this.XUL_NS, "menuitem"); item.setAttribute("value", aValue); if (aLabel) { // XXX: We should use node instead of its text content to add a // label. But we cannot put node into menuitem, therefore we now // use label text and set @label for menulist. item.setAttribute("label", aLabel.textContent); } // XXX: Group supporting isn't implemented this.control.menupopup.appendChild(item); return item; // XXX: Group supporting isn't implemented return null; this.control.selectedItem = aItem; if (this.control.selectedItem == aItem) this.control.selectedItem = null; return aItem.getAttribute("selected") == "true"; if (this.control.getAttribute("editable") == "true") { if (!this.control.selectedItem) return this.control.value; return ""; } if (aAllowed) this.control.setAttribute("editable", "true"); else this.control.removeAttribute("editable"); if (this.control.getAttribute("editable") == "true") { this.control.value = aValue; } this.updateInstanceData(true); this.dispatchDOMUIEvent("DOMFocusIn"); this.updateInstanceData(false); this.dispatchDOMUIEvent("DOMFocusOut"); this.updateInstanceData(true);