Skip to content

Commit 6ffb1f9

Browse files
authored
Send error to event
1 parent 4254978 commit 6ffb1f9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/include-fragment-element.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ export class IncludeFragmentElement extends HTMLElement {
220220
}
221221

222222
// Functional stand in for the W3 spec "queue a task" paradigm
223-
async #task(eventsToDispatch: string[]): Promise<void> {
223+
async #task(eventsToDispatch: string[], error?: Error): Promise<void> {
224224
await new Promise(resolve => setTimeout(resolve, 0))
225225
for (const eventType of eventsToDispatch) {
226-
this.dispatchEvent(new Event(eventType))
226+
this.dispatchEvent(error ? new CustomEvent(eventType, {detail: {error}}) : new Event(eventType))
227227
}
228228
}
229229

@@ -258,7 +258,7 @@ export class IncludeFragmentElement extends HTMLElement {
258258
// Dispatch `error` and `loadend` async to allow
259259
// the `load()` promise to resolve _before_ these
260260
// events are fired.
261-
this.#task(['error', 'loadend'])
261+
this.#task(['error', 'loadend'], error)
262262
throw error
263263
}
264264
}

0 commit comments

Comments
 (0)