mirror of
https://github.com/moodle/moodle.git
synced 2025-07-14 02:46:30 +02:00
MDL-44361 Javascript: Fix js_pending injector Y.io
The previous (slightly whacky) way that we were doing this in previous versions is no longer supported (and was arguably only supported by being buggy). The correct way of doing this is to use a trigger.
This commit is contained in:
@ -667,34 +667,25 @@ M.util.js_pending = function(uniqid) {
|
||||
return M.util.pending_js.length;
|
||||
};
|
||||
|
||||
// Start this asap.
|
||||
M.util.js_pending('init');
|
||||
|
||||
/**
|
||||
* Register listeners for Y.io start/end so we can wait for them in behat.
|
||||
*/
|
||||
M.util.js_watch_io = function() {
|
||||
YUI.add('moodle-core-io', function(Y) {
|
||||
Y.on('io:start', function(id) {
|
||||
M.util.js_pending('io:' + id);
|
||||
});
|
||||
Y.on('io:end', function(id) {
|
||||
M.util.js_complete('io:' + id);
|
||||
});
|
||||
YUI.add('moodle-core-io', function(Y) {
|
||||
Y.on('io:start', function(id) {
|
||||
M.util.js_pending('io:' + id);
|
||||
});
|
||||
YUI.applyConfig({
|
||||
modules: {
|
||||
'moodle-core-io': {
|
||||
after: ['io-base']
|
||||
},
|
||||
'io-base': {
|
||||
requires: ['moodle-core-io'],
|
||||
}
|
||||
}
|
||||
Y.on('io:end', function(id) {
|
||||
M.util.js_complete('io:' + id);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Start this asap.
|
||||
M.util.js_pending('init');
|
||||
M.util.js_watch_io();
|
||||
}, '@VERSION@', {
|
||||
condition: {
|
||||
trigger: 'io-base',
|
||||
when: 'after'
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Unregister any long running javascript code by unique identifier.
|
||||
|
Reference in New Issue
Block a user