From 452cc77168094bbdd4a21209a824020659127859 Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Tue, 27 Jun 2023 11:22:10 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B06446=20Prevent=20loaded=20js=20file=20co?= =?UTF-8?q?nstant=20from=20being=20missing=20if=20an=20ajax=20call=20is=20?= =?UTF-8?q?made=20from=20a=20page=20that's=20not=20a=20Webpage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backoffice/ajaxpage/layout.html.twig | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/templates/pages/backoffice/ajaxpage/layout.html.twig b/templates/pages/backoffice/ajaxpage/layout.html.twig index 0d2c754b06..0551301dac 100644 --- a/templates/pages/backoffice/ajaxpage/layout.html.twig +++ b/templates/pages/backoffice/ajaxpage/layout.html.twig @@ -62,6 +62,26 @@ * ] * ``` */ + + // If these constants aren't defined by the main page, define them (global) ourselves + if (typeof aLoadedJsFilesRegister === "undefined") { + Object.defineProperty(window, "aLoadedJsFilesRegister", { + value: new Map(), + writable: false, + configurable: false, + enumerable: true + }); + } + + if (typeof aLoadedJsFilesResolveCallbacks === "undefined") { + Object.defineProperty(window, "aLoadedJsFilesResolveCallbacks", { + value: new Map(), + writable: false, + configurable: false, + enumerable: true + }); + } + let aJsFilesToLoad = []; /** * @type {Array} aJsFilesToLoadByOtherRequests Files required by the current \AjaxPage but that are already being handled by another request (done or ongoing)