Skip to content

Commit fe7b0a2

Browse files
committed
fix this.httpMethod
1 parent 9dc10b4 commit fe7b0a2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/auto-check-element.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,11 @@ function setLoadingState(event: Event) {
191191

192192
const src = autoCheckElement.src
193193
const csrf = autoCheckElement.csrf
194+
const httpMethod = autoCheckElement.httpMethod
194195
const state = states.get(autoCheckElement)
195196

196197
// If some attributes are missing we want to exit early and make sure that the element is valid.
197-
if (!src || (this.httpMethod === 'POST' && !csrf) || !state) {
198+
if (!src || (httpMethod === 'POST' && !csrf) || !state) {
198199
return
199200
}
200201

@@ -242,9 +243,10 @@ async function check(autoCheckElement: AutoCheckElement) {
242243
const src = autoCheckElement.src
243244
const csrf = autoCheckElement.csrf
244245
const state = states.get(autoCheckElement)
246+
const httpMethod = autoCheckElement.httpMethod
245247

246248
// If some attributes are missing we want to exit early and make sure that the element is valid.
247-
if (!src || (this.httpMethod === 'POST' && !csrf) || !state) {
249+
if (!src || (httpMethod === 'POST' && !csrf) || !state) {
248250
if (autoCheckElement.required) {
249251
input.setCustomValidity('')
250252
}
@@ -259,7 +261,7 @@ async function check(autoCheckElement: AutoCheckElement) {
259261
}
260262

261263
const body = new FormData()
262-
if (this.httpMethod === 'POST') {
264+
if (httpMethod === 'POST') {
263265
body.append(csrfField, csrf)
264266
body.append('value', input.value)
265267
} else {
@@ -281,7 +283,7 @@ async function check(autoCheckElement: AutoCheckElement) {
281283
const response = await fetchWithNetworkEvents(autoCheckElement, src, {
282284
credentials: 'same-origin',
283285
signal: state.controller.signal,
284-
method: this.httpMethod,
286+
method: httpMethod,
285287
body,
286288
})
287289
if (response.ok) {

0 commit comments

Comments
 (0)