From 758621435fa760f69313f8a536a20e5ebd5b3fec Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 28 Sep 2016 18:31:01 +0200 Subject: [PATCH] Add support for errBack to require.linearExecution --- .../files/js/require.linearExecution.js | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/wcfsetup/install/files/js/require.linearExecution.js b/wcfsetup/install/files/js/require.linearExecution.js index 4729d6725d..9f2e40a090 100644 --- a/wcfsetup/install/files/js/require.linearExecution.js +++ b/wcfsetup/install/files/js/require.linearExecution.js @@ -3,7 +3,7 @@ var queue = []; var counter = 0; - window.require = function(dependencies, callback) { + window.require = function(dependencies, callback, errBack) { if (!Array.isArray(dependencies)) { return orgRequire.apply(window, arguments); } @@ -11,13 +11,30 @@ var i = counter++; queue.push(i); - orgRequire(dependencies, function() { - var args = arguments; - - queue[queue.indexOf(i)] = function() { callback.apply(window, args); }; - - executeCallbacks(); - }); + if (errBack) { + orgRequire(dependencies, function() { + var args = arguments; + + queue[queue.indexOf(i)] = function() { callback.apply(window, args); }; + + executeCallbacks(); + }, function() { + var args = arguments; + + queue[queue.indexOf(i)] = function() { errBack.apply(window, args); }; + + executeCallbacks(); + }); + } + else { + orgRequire(dependencies, function() { + var args = arguments; + + queue[queue.indexOf(i)] = function() { callback.apply(window, args); }; + + executeCallbacks(); + }); + } }; window.require.config = orgRequire.config; -- 2.20.1