Merge pull request #19059 from Snuffleupagus/DOMFilterFactory-rm-_hcmCache

Improve clean-up of `#_hcmCache`-data in `DOMFilterFactory.prototype.destroy`
This commit is contained in:
Tim van der Meij 2024-11-17 16:31:37 +01:00 committed by GitHub
commit fc0484904e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
} }