MDL-58317 templates: Fix async template render

There is an edge case where we do not wait for all promises before
rendering a template. This can generate "failed to pre-fetch the template" JS errors.
This commit is contained in:
Damyon Wiese
2017-03-20 13:29:09 +08:00
parent 98c4094eac
commit f4e623b3e7
2 changed files with 4 additions and 3 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+3 -2
View File
@@ -623,9 +623,10 @@ define(['core/mustache',
for (i = 0; i < partials.length; i++) {
var searchKey = this.currentThemeName + '/' + partials[i];
if (searchKey in templatePromises) {
continue;
fetchThemAll.push(templatePromises[searchKey]);
} else {
fetchThemAll.push(this.cachePartials(partials[i]));
}
fetchThemAll.push(this.cachePartials(partials[i]));
}
return $.when.apply($, fetchThemAll).then(function() {