Skip to content

Commit c82bbaf

Browse files
committed
use AutoCheckCompleteEvent for completion events
1 parent ed275fc commit c82bbaf

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/auto-check-element.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ type State = {
1414

1515
const states = new WeakMap<AutoCheckElement, State>()
1616

17+
export class AutoCheckCompleteEvent extends Event {
18+
constructor() {
19+
super('auto-check-complete', {bubbles: true})
20+
}
21+
}
22+
1723
export class AutoCheckElement extends HTMLElement {
1824
static define(tag = 'auto-check', registry = customElements) {
1925
registry.define(tag, this)
@@ -221,11 +227,11 @@ async function check(autoCheckElement: AutoCheckElement) {
221227
processFailure(response, input, autoCheckElement.required)
222228
}
223229
state.controller = null
224-
input.dispatchEvent(new CustomEvent('auto-check-complete', {bubbles: true}))
230+
input.dispatchEvent(new AutoCheckCompleteEvent())
225231
} catch (error) {
226232
if ((error as Error).name !== 'AbortError') {
227233
state.controller = null
228-
input.dispatchEvent(new CustomEvent('auto-check-complete', {bubbles: true}))
234+
input.dispatchEvent(new AutoCheckCompleteEvent())
229235
}
230236
}
231237
}

0 commit comments

Comments
 (0)