Fix Edge form support (#178)

* Fix looping through form elements in Edge

* Update lockfile
This commit was merged in pull request #178.
This commit is contained in:
Robin North
2018-10-10 19:21:04 +02:00
committed by BehindTheMath
parent 6b648a7c90
commit 52fb3bf938
2 changed files with 8 additions and 11 deletions

View File

@@ -45,13 +45,10 @@ var formAction = function(el, event) {
function parseFormElements(el) { function parseFormElements(el) {
var requestParams = [] var requestParams = []
var formElements = el.elements
for (var elementKey in el.elements) { for (var i = 0; i < formElements.length; i++) {
if (Number.isNaN(Number(elementKey))) { var element = formElements[i]
continue;
}
var element = el.elements[elementKey]
var tagName = element.tagName.toLowerCase() var tagName = element.tagName.toLowerCase()
// jscs:disable disallowImplicitTypeConversion // jscs:disable disallowImplicitTypeConversion
if (!!element.name && element.attributes !== undefined && tagName !== "button") { if (!!element.name && element.attributes !== undefined && tagName !== "button") {
@@ -65,8 +62,8 @@ function parseFormElements(el) {
if (tagName === "select") { if (tagName === "select") {
var opt var opt
for (var i = 0; i < element.options.length; i++) { for (var j = 0; j < element.options.length; j++) {
opt = element.options[i] opt = element.options[j]
if (opt.selected && !opt.disabled) { if (opt.selected && !opt.disabled) {
values.push(opt.hasAttribute("value") ? opt.value : opt.text) values.push(opt.hasAttribute("value") ? opt.value : opt.text)
} }
@@ -76,10 +73,10 @@ function parseFormElements(el) {
values.push(element.value) values.push(element.value)
} }
for (var j = 0; j < values.length; j++) { for (var k = 0; k < values.length; k++) {
requestParams.push({ requestParams.push({
name: encodeURIComponent(element.name), name: encodeURIComponent(element.name),
value: encodeURIComponent(values[j]) value: encodeURIComponent(values[k])
}) })
} }
} }

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "pjax", "name": "pjax",
"version": "0.2.5", "version": "0.2.7",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {