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.
This commit is contained in:
committed by
Eloy Lafuente (stronk7)
parent
be7bda671e
commit
8f28fbee11
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("theme_boost/pending",["exports","jquery"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);function c(a,b){return h(a)||g(a,b)||e(a,b)||d()}function d(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function e(a,b){if(!a)return;if("string"==typeof a)return f(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return f(a,b)}function f(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c<b;c++){d[c]=a[c]}return d}function g(a,b){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(a)))return;var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function h(a){if(Array.isArray(a))return a}var i={alert:[{start:"close",end:"closed"}],carousel:[{start:"slide",end:"slid"}],collapse:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}],dropdown:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}],modal:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}],popover:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}],tab:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}],toast:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}],tooltip:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}]};a.default=function(){Object.entries(i).forEach(function(a){var d=c(a,2),e=d[0],f=d[1];f.forEach(function(a){var c="".concat(a.start,".bs.").concat(e),d="".concat(a.end,".bs.").concat(e);(0,b.default)(document.body).on(c,function(){M.util.js_pending(d)});(0,b.default)(document.body).on(d,function(){M.util.js_complete(d)})})})};return a.default});
|
||||
define ("theme_boost/pending",["exports","jquery"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);function c(a,b){return h(a)||g(a,b)||e(a,b)||d()}function d(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function e(a,b){if(!a)return;if("string"==typeof a)return f(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return f(a,b)}function f(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c<b;c++){d[c]=a[c]}return d}function g(a,b){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(a)))return;var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function h(a){if(Array.isArray(a))return a}var i={alert:[{start:"close",end:"closed"}],carousel:[{start:"slide",end:"slid"}],collapse:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}],dropdown:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}],modal:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}],popover:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}],tab:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}],toast:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}],tooltip:[{start:"hide",end:"hidden"},{start:"show",end:"shown"}]};a.default=function(){Object.entries(i).forEach(function(a){var d=c(a,2),e=d[0],f=d[1];f.forEach(function(a){var c="".concat(a.start,".bs.").concat(e),d="".concat(a.end,".bs.").concat(e);(0,b.default)(document.body).on(c,function(a){M.util.js_pending(d);(0,b.default)(a.target).one(d,function(){M.util.js_complete(d)})})})})};return a.default});
|
||||
//# sourceMappingURL=pending.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -121,13 +121,13 @@ export default () => {
|
||||
pairs.forEach(pair => {
|
||||
const eventStart = `${pair.start}.bs.${key}`;
|
||||
const eventEnd = `${pair.end}.bs.${key}`;
|
||||
jQuery(document.body).on(eventStart, () => {
|
||||
jQuery(document.body).on(eventStart, e => {
|
||||
M.util.js_pending(eventEnd);
|
||||
jQuery(e.target).one(eventEnd, () => {
|
||||
M.util.js_complete(eventEnd);
|
||||
});
|
||||
});
|
||||
|
||||
jQuery(document.body).on(eventEnd, () => {
|
||||
M.util.js_complete(eventEnd);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user