This repository was archived by the owner on Oct 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.umd.js
More file actions
61 lines (52 loc) · 1.74 KB
/
index.umd.js
File metadata and controls
61 lines (52 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.formDataEntries = factory());
}(this, (function () { 'use strict';
var formDataEntries;
if (typeof FormData === 'function' && 'entries' in FormData.prototype) {
formDataEntries = function(form) {
return Array.from(new FormData(form).entries())
};
} else {
formDataEntries = function(form) {
var entries = [];
var elements = form.elements;
for (var i = 0; i < elements.length; i++) {
var el = elements[i];
var tagName = el.tagName.toUpperCase();
if (tagName === 'SELECT' || tagName === 'TEXTAREA' || tagName === 'INPUT') {
var type = el.type,
name = el.name;
if (
name &&
!el.disabled &&
type !== 'submit' &&
type !== 'reset' &&
type !== 'button' &&
((type !== 'radio' && type !== 'checkbox') || el.checked)
) {
if (tagName === 'SELECT') {
var options = el.getElementsByTagName('option');
for (var j = 0; j < options.length; j++) {
var option = options[j];
if (option.selected) {
entries.push([name, option.value]);
}
}
} else if (type === 'file') {
// eslint-disable-next-line no-console
console.warn('form-data-entries could not serialize <input type=file>', el);
entries.push([name, '']);
} else {
entries.push([name, el.value]);
}
}
}
}
return entries
};
}
var formDataEntries$1 = formDataEntries
return formDataEntries$1;
})));