@glitchr/transparent 1.0.48 → 1.0.50
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/src/js/transparent.js +18 -8
package/package.json
CHANGED
package/src/js/transparent.js
CHANGED
|
@@ -547,7 +547,10 @@
|
|
|
547
547
|
return null;
|
|
548
548
|
}
|
|
549
549
|
|
|
550
|
-
if(!form.checkValidity())
|
|
550
|
+
if(!$(el).hasClass("skip-validation") && !form.checkValidity()) {
|
|
551
|
+
console.error("Invalid form submission.", el);
|
|
552
|
+
return null;
|
|
553
|
+
}
|
|
551
554
|
|
|
552
555
|
var pat = /^https?:\/\//i;
|
|
553
556
|
if (pat.test(href)) return [method, new URL(href), form];
|
|
@@ -589,7 +592,10 @@
|
|
|
589
592
|
return null;
|
|
590
593
|
}
|
|
591
594
|
|
|
592
|
-
if(!form.checkValidity())
|
|
595
|
+
if(!$(el).hasClass("skip-validation") && !form.checkValidity()) {
|
|
596
|
+
console.error("Invalid form submission.", el);
|
|
597
|
+
return null;
|
|
598
|
+
}
|
|
593
599
|
|
|
594
600
|
var pat = /^https?:\/\//i;
|
|
595
601
|
if (pat.test(href)) return ["POST", new URL(pathname), form];
|
|
@@ -1457,7 +1463,7 @@
|
|
|
1457
1463
|
|
|
1458
1464
|
var formInput = undefined; // In case of form ambiguity (two form with same name, restrict the data to the target form, if not extends it to each element with standard name)
|
|
1459
1465
|
if(formAmbiguity) formInput = $(form).find(":input, [name^='"+form.name+"\[']");
|
|
1460
|
-
else $("form[name='"+form.name+"'] :input, [name^='"+form.name+"\[']");
|
|
1466
|
+
else formInput = $("form[name='"+form.name+"'] :input, [name^='"+form.name+"\[']");
|
|
1461
1467
|
|
|
1462
1468
|
formInput.each(function() {
|
|
1463
1469
|
|
|
@@ -1718,7 +1724,7 @@
|
|
|
1718
1724
|
window.onhashchange = __main__;
|
|
1719
1725
|
|
|
1720
1726
|
var formDataBefore = {};
|
|
1721
|
-
$(window).on("
|
|
1727
|
+
$(window).on("load", function() {
|
|
1722
1728
|
|
|
1723
1729
|
formDataBefore = {};
|
|
1724
1730
|
$("form").each(function() {
|
|
@@ -1748,6 +1754,8 @@
|
|
|
1748
1754
|
if(formSubmission) return; // Do not display on form submission
|
|
1749
1755
|
if(Settings.disable) return;
|
|
1750
1756
|
|
|
1757
|
+
if(e.currentTarget == window) return;
|
|
1758
|
+
|
|
1751
1759
|
var preventDefault = false;
|
|
1752
1760
|
var formDataAfter = [];
|
|
1753
1761
|
$("form").each(function() {
|
|
@@ -1775,15 +1783,15 @@
|
|
|
1775
1783
|
var formDataAfterKeys = Object.keys(formDataAfter);
|
|
1776
1784
|
var formDataBeforeEntries = Object.entries(formDataBefore);
|
|
1777
1785
|
var formDataAfterEntries = Object.entries(formDataAfter);
|
|
1778
|
-
function
|
|
1779
|
-
function
|
|
1786
|
+
function same(a, b) { return JSON.stringify(a) === JSON.stringify(b); }
|
|
1787
|
+
function sameKeys(a, b) {
|
|
1780
1788
|
|
|
1781
1789
|
var aKeys = Object.keys(a).sort();
|
|
1782
1790
|
var bKeys = Object.keys(b).sort();
|
|
1783
1791
|
return JSON.stringify(aKeys) === JSON.stringify(bKeys);
|
|
1784
1792
|
}
|
|
1785
1793
|
|
|
1786
|
-
if(!
|
|
1794
|
+
if(!sameKeys(formDataBeforeKeys, formDataAfterKeys)) preventDefault = true;
|
|
1787
1795
|
else {
|
|
1788
1796
|
|
|
1789
1797
|
for (var [fieldName,fieldValueAfter] of Object.entries(formDataAfter)) {
|
|
@@ -1794,7 +1802,9 @@
|
|
|
1794
1802
|
if(!fieldValueAfter instanceof File) preventDefault = true;
|
|
1795
1803
|
else if (fieldValueBefore.size != fieldValueAfter.size) preventDefault = true;
|
|
1796
1804
|
|
|
1797
|
-
} else if(fieldValueBefore != fieldValueAfter)
|
|
1805
|
+
} else if(fieldValueBefore != fieldValueAfter) {
|
|
1806
|
+
preventDefault = true;
|
|
1807
|
+
}
|
|
1798
1808
|
}
|
|
1799
1809
|
}
|
|
1800
1810
|
|