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:
Andrew Nicols
2014-02-26 16:01:40 +08:00
parent 4d24e65cb8
commit 051548b897

View File

@ -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.