Add custom event for loading manifest item (#76)

This commit is contained in:
Huang Xin
2025-08-01 23:44:52 +00:00
committed by GitHub
parent 9fd2209b4d
commit bdae473012
+5 -2
View File
@@ -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)