hook priority position should default to 0, not end

This commit is contained in:
jesopo 2019-07-30 15:09:34 +01:00
parent 0969127a36
commit ff0cc59507

View file

@ -148,14 +148,13 @@ class EventRoot(object):
self._hooks[path_str] = [] self._hooks[path_str] = []
hook_array = self._hooks[path_str] hook_array = self._hooks[path_str]
hooked = False hook_position = 0
for i, other_hook in enumerate(hook_array): for i, other_hook in enumerate(hook_array):
if other_hook.priority > new_hook.priority: if other_hook.priority > new_hook.priority:
hooked = True hook_position = i
hook_array.insert(i, new_hook)
break break
if not hooked:
hook_array.append(new_hook) hook_array.insert(hook_position, new_hook)
return new_hook return new_hook
def _call(self, path: typing.List[str], kwargs: dict, safe: bool, def _call(self, path: typing.List[str], kwargs: dict, safe: bool,