Add destroy method

Which revokes all blob URLs and removes the element from document.
This commit is contained in:
John Factotum
2023-05-09 14:02:07 +08:00
parent a817932b08
commit 5da3be5200
7 changed files with 45 additions and 5 deletions
+7
View File
@@ -842,6 +842,10 @@ class MOBI6 {
isExternal(uri) {
return /^(?!blob|filepos)\w+:/i.test(uri)
}
destroy() {
for (const url of this.#resourceCache.values()) URL.revokeObjectURL(url)
for (const url of this.#cache.values()) URL.revokeObjectURL(url)
}
}
// handlers for `kindle:` uris
@@ -1154,4 +1158,7 @@ class KF8 {
isExternal(uri) {
return /^(?!blob|kindle)\w+:/i.test(uri)
}
destroy() {
for (const url of this.#cache.values()) URL.revokeObjectURL(url)
}
}