diff --git a/core/modules/big_pipe/js/big_pipe.es6.js b/core/modules/big_pipe/js/big_pipe.es6.js index 647f38f022..54ae253465 100644 --- a/core/modules/big_pipe/js/big_pipe.es6.js +++ b/core/modules/big_pipe/js/big_pipe.es6.js @@ -3,7 +3,7 @@ * Renders BigPipe placeholders using Drupal's Ajax system. */ -(function (Drupal, drupalSettings) { +(function (window, Drupal, drupalSettings) { const placeholderIdAttr = 'data-big-pipe-replacement-for-placeholder-with-id'; const replacementsSelector = `script[${placeholderIdAttr}]`; @@ -94,9 +94,15 @@ // As soon as the document is loaded, no more replacements will be added. // Immediately fetch and process all pending mutations and stop the observer. - window.addEventListener('DOMContentLoaded', () => { - const mutations = observer.takeRecords(); - observer.disconnect(); - processMutations(mutations); - }); -})(Drupal, drupalSettings); + window.Drupal.bigPipeProcessMutationsCallback = + drupalSettings.processMutationsCallback || + function processMutationsCallback() { + const mutations = observer.takeRecords(); + observer.disconnect(); + processMutations(mutations); + }; + window.addEventListener( + 'DOMContentLoaded', + window.Drupal.bigPipeProcessMutationsCallback, + ); +})(window, Drupal, drupalSettings); diff --git a/core/modules/big_pipe/js/big_pipe.js b/core/modules/big_pipe/js/big_pipe.js index 34a21c6b4e..db22ee99e8 100644 --- a/core/modules/big_pipe/js/big_pipe.js +++ b/core/modules/big_pipe/js/big_pipe.js @@ -5,7 +5,7 @@ * @preserve **/ -(function (Drupal, drupalSettings) { +(function (window, Drupal, drupalSettings) { var placeholderIdAttr = 'data-big-pipe-replacement-for-placeholder-with-id'; var replacementsSelector = "script[".concat(placeholderIdAttr, "]"); @@ -60,9 +60,12 @@ observer.observe(document.body, { childList: true }); - window.addEventListener('DOMContentLoaded', function () { + + window.Drupal.bigPipeProcessMutationsCallback = drupalSettings.processMutationsCallback || function processMutationsCallback() { var mutations = observer.takeRecords(); observer.disconnect(); processMutations(mutations); - }); -})(Drupal, drupalSettings); \ No newline at end of file + }; + + window.addEventListener('DOMContentLoaded', window.Drupal.bigPipeProcessMutationsCallback); +})(window, Drupal, drupalSettings); \ No newline at end of file