From: Tim Düsterhus Date: Fri, 22 May 2015 18:59:51 +0000 (+0200) Subject: Add “forall” support to WoltLab/WCF/CallbackList.forEach X-Git-Tag: 3.0.0_Beta_1~2350^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d71860cc72190173dbfc5c8740ef5bc564b3a0ce;p=GitHub%2FWoltLab%2FWCF.git Add “forall” support to WoltLab/WCF/CallbackList.forEach --- 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); + } } } };