From b1cbcfa842abf670c2b5805eb45bc8314836bb2d Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Wed, 24 Aug 2011 15:55:09 -0700 Subject: Fixes #3589. JS "all" hook handlers called only once. --- js/lib/hooks.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/js/lib/hooks.js b/js/lib/hooks.js index eeaffb846..ab3a8a224 100644 --- a/js/lib/hooks.js +++ b/js/lib/hooks.js @@ -77,11 +77,23 @@ elgg.trigger_hook = function(name, type, params, value) { elgg.provide(name + '.all', hooks); elgg.provide('all.all', hooks); - [ hooks[name][type], - hooks['all'][type], - hooks[name]['all'], - hooks['all']['all'] - ].every(function(handlers) { + var hooksList = []; + + if (name != 'all' && type != 'all') { + hooksList.push(hooks[name][type]); + } + + if (type != 'all') { + hooksList.push(hooks['all'][type]); + } + + if (name != 'all') { + hooksList.push(hooks[name]['all']); + } + + hooksList.push(hooks['all']['all']); + + hooksList.every(function(handlers) { if (handlers instanceof elgg.ElggPriorityList) { handlers.forEach(callHookHandler); } -- cgit v1.2.3