Skip to content

Commit e755c96

Browse files
committed
dont dispatch auto-check-complete if auto-check-send hasn't been emitted
1 parent e7bf1e2 commit e755c96

File tree

2 files changed

+1
-24
lines changed

2 files changed

+1
-24
lines changed

src/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ async function check(autoCheckElement: AutoCheckElement) {
151151
if (autoCheckElement.required) {
152152
input.setCustomValidity('')
153153
}
154-
input.dispatchEvent(new CustomEvent('auto-check-complete', {bubbles: true}))
155154
return
156155
}
157156

@@ -160,17 +159,13 @@ async function check(autoCheckElement: AutoCheckElement) {
160159
body.append('value', input.value)
161160

162161
const id = body.entries ? [...body.entries()].sort().toString() : null
163-
if (id && id === state.previousValue) {
164-
input.dispatchEvent(new CustomEvent('auto-check-complete', {bubbles: true}))
165-
return
166-
}
162+
if (id && id === state.previousValue) return
167163
state.previousValue = id
168164

169165
if (!input.value.trim()) {
170166
if (autoCheckElement.required) {
171167
input.setCustomValidity('')
172168
}
173-
input.dispatchEvent(new CustomEvent('auto-check-complete', {bubbles: true}))
174169
return
175170
}
176171

test/test.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,6 @@ describe('auto-check element', function() {
5151
assert.isFalse(input.checkValidity())
5252
})
5353

54-
it('validates the input element if there is no `src` attribute', async function() {
55-
checker.removeAttribute('src')
56-
const completeEvent = once(checker, 'auto-check-complete')
57-
triggerChange(input, 'hub')
58-
await completeEvent
59-
assert.isTrue(input.checkValidity())
60-
checker.src = '/success'
61-
})
62-
63-
it('validates the input element if there is no `csrf` attribute', async function() {
64-
checker.removeAttribute('csrf')
65-
const completeEvent = once(checker, 'auto-check-complete')
66-
triggerChange(input, 'hub')
67-
await completeEvent
68-
assert.isTrue(input.checkValidity())
69-
checker.csrf = 'foo'
70-
})
71-
7254
it('invalidates input request is in-flight', async function() {
7355
triggerChange(input, 'hub')
7456
await once(checker, 'loadstart')

0 commit comments

Comments
 (0)