From: Tim Düsterhus Date: Wed, 28 Sep 2016 16:31:01 +0000 (+0200) Subject: Add support for errBack to require.linearExecution X-Git-Tag: 3.0.0_Beta_2~78 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=758621435fa760f69313f8a536a20e5ebd5b3fec;p=GitHub%2FWoltLab%2FWCF.git Add support for errBack to require.linearExecution --- 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;