Commit c2724bce authored by Andrew Nicols's avatar Andrew Nicols
Browse files

MDL-69086 theme_boost: Improve pendingJs checks for bootstrap

Where an element, like an `alert`, is closed it is removed from the DOM
before the event fires (this is a correct behaviour).

This means that the final event confirming that the action happened
(i.e. close => closed) fires, but does not bubble up the DOM to the
document.body.

This change moves the end event listener to only be added after a start
event has been fired, and to attach directly to the HTMLElement where it
will be fired. This means that the Event handler will still be called,
even though it has been removed from the DOM, because it does not need
to bubble up to the body.
parent 4762e10f
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -108,12 +108,11 @@ define(['jquery'], function($) {
moduleTransitions[key].forEach(function(pair) {
var eventStart = pair.start + '.bs.' + key;
var eventEnd = pair.end + '.bs.' + key;
$(document.body).on(eventStart, function() {
$(document.body).on(eventStart, function(e) {
M.util.js_pending(eventEnd);
});
$(document.body).on(eventEnd, function() {
M.util.js_complete(eventEnd);
$(e.target).one(eventEnd, function() {
M.util.js_complete(eventEnd);
});
});
});
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment