Motivation
Sometimes Prism has to reload languages (and soon plugins). This is a problem because the added hooks cannot be removed which will lead to multiple runs of the same hook.
Even if this doesn't cause highlighting issues, it's just unnecessary CPU time to execute the same hook multiple times.
Description
Require all callbacks added to a specific hook to have a name. The name of a callback should be the id of the language/plugin which added it.
If no name is provided, the callback will still be added but cannot be removed.
A new method Prism.hooks.remove(name: string): void
can then be used to remove the callbacks of all hooks with the given name.
Alternatives
Instead of introducing a remove
method, we could modify the add
method to overwrite old callbacks with the same name. Callbacks without a name won't be overwritten.
Related: #459
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4