зеркало из https://github.com/mozilla/gecko-dev.git
Bug 891736 - Make XUL menulist fire events. r=mfinkle
This commit is contained in:
Родитель
ac295a246e
Коммит
916aef0476
|
@ -41,10 +41,13 @@ var SelectHelper = {
|
|||
if (selected == -1)
|
||||
return;
|
||||
|
||||
let changed = false;
|
||||
if (aElement instanceof Ci.nsIDOMXULMenuListElement) {
|
||||
if (aElement.selectedIndex != selected) {
|
||||
aElement.selectedIndex = selected;
|
||||
this.fireOnCommand(aElement);
|
||||
}
|
||||
} else if (aElement instanceof HTMLSelectElement) {
|
||||
let changed = false;
|
||||
if (!Array.isArray(selected)) {
|
||||
let temp = [];
|
||||
for (let i = 0; i <= list.length; i++) {
|
||||
|
@ -61,10 +64,10 @@ var SelectHelper = {
|
|||
}
|
||||
i++
|
||||
});
|
||||
}
|
||||
|
||||
if (changed)
|
||||
this.fireOnChange(aElement);
|
||||
}
|
||||
}).bind(this));
|
||||
},
|
||||
|
||||
|
@ -128,5 +131,15 @@ var SelectHelper = {
|
|||
setTimeout(function() {
|
||||
aElement.dispatchEvent(evt);
|
||||
}, 0);
|
||||
},
|
||||
|
||||
fireOnCommand: function(aElement) {
|
||||
let evt = aElement.ownerDocument.createEvent("XULCommandEvent");
|
||||
evt.initCommandEvent("command", true, true, aElement.defaultView, 0,
|
||||
false, false,
|
||||
false, false, null);
|
||||
setTimeout(function() {
|
||||
aElement.dispatchEvent(evt);
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче