API for deleting core hooks (#7751)

* feat: Delete hooks from the hashmap

* fix: not using findIndex in the core

* Update HookMechanism.tid
This commit is contained in:
lin onetwo
2023-09-24 21:54:52 +01:00
committed by GitHub
parent 8effb3f218
commit 773c1f83f2
2 changed files with 40 additions and 3 deletions
+12
View File
@@ -2674,6 +2674,18 @@ $tw.hooks.addHook = function(hookName,definition) {
}
};
/*
Delete hooks from the hashmap
*/
$tw.hooks.removeHook = function(hookName,definition) {
if($tw.utils.hop($tw.hooks.names,hookName)) {
var p = $tw.hooks.names[hookName].indexOf(definition);
if(p !== -1) {
$tw.hooks.names[hookName].splice(p, 1);
}
}
};
/*
Invoke the hook by key
*/