Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit75ac8d9

Browse files
authored
Merge pull request#108 from github/manuelpuyol-patch-1
Send error information to event
2 parents4254978 +45014a6 commit75ac8d9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-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
awaitnewPromise(resolve=>setTimeout(resolve,0))
225225
for(consteventTypeofeventsToDispatch){
226-
this.dispatchEvent(newEvent(eventType))
226+
this.dispatchEvent(error ?newCustomEvent(eventType,{detail:{error}}) :newEvent(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'],errorasError)
262262
throwerror
263263
}
264264
}

‎test/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ suite('include-fragment-element', function () {
342342
constevent=awaitwhen(div.firstChild,'error')
343343
assert.equal(event.bubbles,false)
344344
assert.equal(event.cancelable,false)
345+
assert.instanceOf(event.detail.error,Error)
346+
assert.equal(event.detail.error.message,'Failed to load resource: the server responded with a status of 500')
345347
})
346348

347349
test('adds is-error class on 500 status',asyncfunction(){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp