rytm-webflow 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/aswap/ASwapDispatcher.js +16 -18
package/package.json
CHANGED
|
@@ -384,7 +384,7 @@ class ASwapDispatcher extends EventDispatcher {
|
|
|
384
384
|
isFormElementValid(f) {
|
|
385
385
|
let result = false
|
|
386
386
|
if (f) {
|
|
387
|
-
if (!f.classList.contains(this.noSwapClassName)) {
|
|
387
|
+
if (f.matches(this.formsSelector) && !f.classList.contains(this.noSwapClassName)) {
|
|
388
388
|
result = true
|
|
389
389
|
}
|
|
390
390
|
}
|
|
@@ -424,25 +424,23 @@ class ASwapDispatcher extends EventDispatcher {
|
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
426
|
onDocumentSubmit(e) {
|
|
427
|
-
e.
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
this.submit(requestUrl, dataStr, method, false, useCache)
|
|
442
|
-
}
|
|
427
|
+
if (e.target.tagName == 'FORM') {
|
|
428
|
+
const f = e.target
|
|
429
|
+
if (this.isFormElementValid(f)) {
|
|
430
|
+
e.preventDefault();
|
|
431
|
+
const useCache = !f.classList.contains(this.noCacheClassName);
|
|
432
|
+
const url = f.getAttribute("action");
|
|
433
|
+
if (url.indexOf('://') < 0) {
|
|
434
|
+
e.preventDefault()
|
|
435
|
+
this.currentTrigger = f
|
|
436
|
+
const method = f.getAttribute('method') ? f.getAttribute('method') : 'get'
|
|
437
|
+
const dataStr = new URLSearchParams(new FormData(f)).toString()
|
|
438
|
+
const requestUrl = method == 'get' ? (url + '?' + dataStr) : url
|
|
439
|
+
this.submit(requestUrl, dataStr, method, false, useCache)
|
|
440
|
+
}
|
|
443
441
|
|
|
442
|
+
}
|
|
444
443
|
}
|
|
445
|
-
|
|
446
444
|
}
|
|
447
445
|
/**
|
|
448
446
|
* add event listeners
|