Improve clean-up of #_hcmCache-data in DOMFilterFactory.prototype.destroy
- Use optional chaining when clearing various data-structures, since that's slightly shorter. - Ensure that checking for the existence of `#_hcmCache`-data won't cause it to be initialized. (Note how `this.#hcmCache` is actually a getter.) - Actually reset the `#_hcmCache`-data when that's appropriate, e.g. when closing the PDF document.
This commit is contained in:
parent
bc91985941
commit
4c57ec4da7
@ -423,17 +423,18 @@ class DOMFilterFactory extends BaseFilterFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy(keepHCM = false) {
|
destroy(keepHCM = false) {
|
||||||
if (keepHCM && this.#hcmCache.size !== 0) {
|
if (keepHCM && this.#_hcmCache?.size) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.#_defs) {
|
this.#_defs?.parentNode.parentNode.remove();
|
||||||
this.#_defs.parentNode.parentNode.remove();
|
this.#_defs = null;
|
||||||
this.#_defs = null;
|
|
||||||
}
|
this.#_cache?.clear();
|
||||||
if (this.#_cache) {
|
this.#_cache = null;
|
||||||
this.#_cache.clear();
|
|
||||||
this.#_cache = null;
|
this.#_hcmCache?.clear();
|
||||||
}
|
this.#_hcmCache = null;
|
||||||
|
|
||||||
this.#id = 0;
|
this.#id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user