modalDialog: Don't use a for...in loop for iterating over arrays.
for...in loops do not guarantee that the indexes iterate in order. As a consequence, buttons may appear in an undesired order.
This commit is contained in:
parent
824220356f
commit
4352cc231e
@ -110,9 +110,8 @@ ModalDialog.prototype = {
|
|||||||
this._buttonLayout.destroy_children();
|
this._buttonLayout.destroy_children();
|
||||||
this._actionKeys = {};
|
this._actionKeys = {};
|
||||||
|
|
||||||
let i = 0;
|
for (let i = 0; i < buttons.length; i ++) {
|
||||||
for (let index in buttons) {
|
let buttonInfo = buttons[i];
|
||||||
let buttonInfo = buttons[index];
|
|
||||||
let label = buttonInfo['label'];
|
let label = buttonInfo['label'];
|
||||||
let action = buttonInfo['action'];
|
let action = buttonInfo['action'];
|
||||||
let key = buttonInfo['key'];
|
let key = buttonInfo['key'];
|
||||||
@ -144,11 +143,10 @@ ModalDialog.prototype = {
|
|||||||
|
|
||||||
if (key)
|
if (key)
|
||||||
this._actionKeys[key] = action;
|
this._actionKeys[key] = action;
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fade in buttons if there weren't any before
|
// Fade in buttons if there weren't any before
|
||||||
if (!hadChildren && i > 0) {
|
if (!hadChildren && buttons.length > 0) {
|
||||||
this._buttonLayout.opacity = 0;
|
this._buttonLayout.opacity = 0;
|
||||||
Tweener.addTween(this._buttonLayout,
|
Tweener.addTween(this._buttonLayout,
|
||||||
{ opacity: 255,
|
{ opacity: 255,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user