mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Add custom event for loading manifest item (#76)
This commit is contained in:
@@ -706,7 +706,6 @@ class Loader {
|
||||
#cache = new Map()
|
||||
#children = new Map()
|
||||
#refCount = new Map()
|
||||
allowScript = false
|
||||
eventTarget = new EventTarget()
|
||||
constructor({ loadText, loadBlob, resources }) {
|
||||
this.loadText = loadText
|
||||
@@ -765,7 +764,11 @@ class Loader {
|
||||
const { href, mediaType } = item
|
||||
|
||||
const isScript = MIME.JS.test(item.mediaType)
|
||||
if (isScript && !this.allowScript) return null
|
||||
const detail = { type: mediaType, isScript, allow: true}
|
||||
const event = new CustomEvent('load', { detail })
|
||||
this.eventTarget.dispatchEvent(event)
|
||||
const allow = await event.detail.allow
|
||||
if (!allow) return null
|
||||
|
||||
const parent = parents.at(-1)
|
||||
if (this.#cache.has(href)) return this.ref(href, parent)
|
||||
|
||||
Reference in New Issue
Block a user