Skip to content

Commit

Permalink
netteForms: modernized code
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 15, 2023
1 parent 387cc53 commit fc2a018
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/assets/netteForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,8 @@

dialog.setAttribute('class', 'netteFormsModal');
dialog.innerText = message + '\n\n';
dialog.appendChild(style);
dialog.appendChild(button);
document.body.appendChild(dialog);
dialog.append(style, button);
document.body.append(dialog);
dialog.showModal();
};

Expand Down Expand Up @@ -369,7 +368,7 @@
filled: function(elem, arg, val) {
return val !== '' && val !== false && val !== null
&& (!Array.isArray(val) || !!val.length)
&& (!window.FileList || !(val instanceof window.FileList) || val.length);
&& (!(val instanceof FileList) || val.length);
},

blank: function(elem, arg, val) {
Expand Down Expand Up @@ -458,7 +457,7 @@
regExp = new RegExp('^(?:' + arg + ')$', caseInsensitive ? 'i' : '');
}

if (window.FileList && val instanceof FileList) {
if (val instanceof FileList) {
for (var i = 0; i < val.length; i++) {
if (!regExp.test(val[i].name)) {
return false;
Expand Down Expand Up @@ -511,11 +510,9 @@
},

fileSize: function(elem, arg, val) {
if (window.FileList) {
for (var i = 0; i < val.length; i++) {
if (val[i].size > arg) {
return false;
}
for (var i = 0; i < val.length; i++) {
if (val[i].size > arg) {
return false;
}
}
return true;
Expand All @@ -528,7 +525,7 @@
}
re = new RegExp(re.join('|'));

if (window.FileList && val instanceof FileList) {
if (val instanceof FileList) {
for (i = 0; i < val.length; i++) {
if (val[i].type && !re.test(val[i].type)) {
return false;
Expand Down Expand Up @@ -682,7 +679,7 @@
elem = document.createElement('input');
elem.setAttribute('name', name);
elem.setAttribute('type', 'hidden');
form.appendChild(elem);
form.append(elem);
}
form.elements[name].value = values[name].join(',');
form.elements[name].disabled = values[name].length === 0;
Expand Down

0 comments on commit fc2a018

Please sign in to comment.