From d71860cc72190173dbfc5c8740ef5bc564b3a0ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 22 May 2015 20:59:51 +0200 Subject: [PATCH] =?utf8?q?Add=20=E2=80=9Cforall=E2=80=9D=20support=20to=20?= =?utf8?q?WoltLab/WCF/CallbackList.forEach?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../install/files/js/WoltLab/WCF/CallbackList.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLab/WCF/CallbackList.js b/wcfsetup/install/files/js/WoltLab/WCF/CallbackList.js index fab271bd75..f932b225cb 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/CallbackList.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/CallbackList.js @@ -46,13 +46,21 @@ define(['Dictionary'], function(Dictionary) { /** * Invokes callback function on each registered callback. * - * @param {string} identifier arbitrary string to group and identify callbacks + * @param {string|null} identifier arbitrary string to group and identify callbacks. + * null is a wildcard to match every identifier * @param {function(function)} callback function called with the individual callback as parameter */ forEach: function(identifier, callback) { - var callbacks = this._dictionary.get(identifier); - if (callbacks !== undefined) { - callbacks.forEach(callback); + if (identifier === null) { + this._dictionary.forEach(function(callbacks, identifier) { + callbacks.forEach(callback); + }); + } + else { + var callbacks = this._dictionary.get(identifier); + if (callbacks !== undefined) { + callbacks.forEach(callback); + } } } }; -- 2.20.1