Skip to content

Commit

Permalink
MDL-69086 theme_boost: Improve pendingJs checks for bootstrap
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andrewnicols committed Jun 19, 2020
1 parent 898415e commit 2dc698f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion theme/boost/amd/build/pending.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion theme/boost/amd/build/pending.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions theme/boost/amd/src/pending.js
Expand Up @@ -119,12 +119,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);
});
});
});
});
Expand Down

0 comments on commit 2dc698f

Please sign in to comment.