mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-63667 javascript: fix failed to pre-fetch the template error
This commit is contained in:
parent
c2f1dbcf49
commit
0015f5b8f1
2 changed files with 18 additions and 13 deletions
2
lib/amd/build/templates.min.js
vendored
2
lib/amd/build/templates.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -50,6 +50,9 @@ define(['core/mustache',
|
||||||
/** @var {Promise[]} templatePromises - Cache of already loaded template promises */
|
/** @var {Promise[]} templatePromises - Cache of already loaded template promises */
|
||||||
var templatePromises = {};
|
var templatePromises = {};
|
||||||
|
|
||||||
|
/** @var {Promise[]} cachePartialPromises - Cache of already loaded template partial promises */
|
||||||
|
var cachePartialPromises = {};
|
||||||
|
|
||||||
/** @var {Object} iconSystem - Object extending core/iconsystem */
|
/** @var {Object} iconSystem - Object extending core/iconsystem */
|
||||||
var iconSystem = {};
|
var iconSystem = {};
|
||||||
|
|
||||||
|
@ -648,24 +651,26 @@ define(['core/mustache',
|
||||||
* @return {Promise} JQuery promise object resolved when all partials are in the cache.
|
* @return {Promise} JQuery promise object resolved when all partials are in the cache.
|
||||||
*/
|
*/
|
||||||
Renderer.prototype.cachePartials = function(templateName) {
|
Renderer.prototype.cachePartials = function(templateName) {
|
||||||
return this.getTemplate(templateName).then(function(templateSource) {
|
var searchKey = this.currentThemeName + '/' + templateName;
|
||||||
var i;
|
|
||||||
var partials = this.scanForPartials(templateSource);
|
|
||||||
var fetchThemAll = [];
|
|
||||||
|
|
||||||
for (i = 0; i < partials.length; i++) {
|
if (searchKey in cachePartialPromises) {
|
||||||
var searchKey = this.currentThemeName + '/' + partials[i];
|
return cachePartialPromises[searchKey];
|
||||||
if (searchKey in templatePromises) {
|
}
|
||||||
fetchThemAll.push(templatePromises[searchKey]);
|
|
||||||
} else {
|
var cachePartialPromise = this.getTemplate(templateName).then(function(templateSource) {
|
||||||
fetchThemAll.push(this.cachePartials(partials[i]));
|
var partials = this.scanForPartials(templateSource);
|
||||||
}
|
var fetchThemAll = partials.map(function(partialName) {
|
||||||
}
|
return this.cachePartials(partialName);
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
return $.when.apply($, fetchThemAll).then(function() {
|
return $.when.apply($, fetchThemAll).then(function() {
|
||||||
return templateSource;
|
return templateSource;
|
||||||
});
|
});
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
cachePartialPromises[searchKey] = cachePartialPromise;
|
||||||
|
|
||||||
|
return cachePartialPromise;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue