Skip to content

Commit

Permalink
updated netteForms.js
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 22, 2024
1 parent 4090f3d commit 7442755
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
16 changes: 3 additions & 13 deletions src/assets/netteForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@
validateForm(sender, onlyCheck = false) {
let form = sender.form ?? sender, scope;
this.formErrors = [];
if (form['nette-submittedBy'] && form['nette-submittedBy'].getAttribute('formnovalidate') !== null) {
let scopeArr = JSON.parse(form['nette-submittedBy'].getAttribute('data-nette-validation-scope') ?? '[]');
if (sender.getAttribute('formnovalidate') !== null) {
let scopeArr = JSON.parse(sender.getAttribute('data-nette-validation-scope') ?? '[]');
if (scopeArr.length) {
scope = new RegExp('^(' + scopeArr.join('-|') + '-)');
}
Expand Down Expand Up @@ -519,7 +519,7 @@
}
form.noValidate = true;
form.addEventListener('submit', (e) => {
if (!this.validateForm(form)) {
if (!this.validateForm(form.submitter || form)) {
e.stopPropagation();
e.preventDefault();
}
Expand All @@ -532,16 +532,6 @@
this.#onDocumentReady(() => {
Array.from(document.forms)
.forEach((form) => this.initForm(form));
document.body.addEventListener('click', (e) => {
let target = e.target;
while (target) {
if (target.form && target.type in { submit: 1, image: 1 }) {
target.form['nette-submittedBy'] = target;
break;
}
target = target.parentNode;
}
});
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/assets/netteForms.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7442755

Please sign in to comment.