Bug 1075226 - Use Array.map in Updater_fillEmptyCells r=ttaubert

This commit is contained in:
Erik Vold 2014-10-15 22:26:42 -07:00
Родитель d506248633
Коммит e1a9cfd648
1 изменённых файлов: 5 добавлений и 8 удалений

Просмотреть файл

@ -154,14 +154,13 @@ let gUpdater = {
*/ */
_fillEmptyCells: function Updater_fillEmptyCells(aLinks, aCallback) { _fillEmptyCells: function Updater_fillEmptyCells(aLinks, aCallback) {
let {cells, sites} = gGrid; let {cells, sites} = gGrid;
let batch = [];
// Find empty cells and fill them. // Find empty cells and fill them.
sites.forEach(function (aSite, aIndex) { Promise.all(sites.map((aSite, aIndex) => {
if (aSite || !aLinks[aIndex]) if (aSite || !aLinks[aIndex])
return; return null;
batch.push(new Promise(resolve => { return new Promise(resolve => {
// Create the new site and fade it in. // Create the new site and fade it in.
let site = gGrid.createSite(aLinks[aIndex], cells[aIndex]); let site = gGrid.createSite(aLinks[aIndex], cells[aIndex]);
@ -172,9 +171,7 @@ let gUpdater = {
// the fade-in transition work. // the fade-in transition work.
window.getComputedStyle(site.node).opacity; window.getComputedStyle(site.node).opacity;
gTransformation.showSite(site, resolve); gTransformation.showSite(site, resolve);
})); });
}); })).then(aCallback).catch(console.exception);
Promise.all(batch).then(aCallback);
} }
}; };