From d566b4b44e8e9e32741da165783e8e59d5e381c7 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Sun, 5 Mar 2017 21:47:50 -0500 Subject: [PATCH 001/108] Adds build badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d4218ed..f8b49593 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#jQuery Form +#jQuery Form [![Build Status](https://travis-ci.org/jquery-form/form.svg?branch=master)](https://travis-ci.org/jquery-form/form) ##Overview The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. The main methods, ajaxForm and ajaxSubmit, gather information from the form element to determine how to manage the submit process. Both of these methods support numerous options which allows you to have full control over how the data is submitted. From 911efdffc75c4f8636ef74db3af610ef3c178eb2 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 6 Mar 2017 20:44:11 -0500 Subject: [PATCH 002/108] test: Adds test 'formToArray: text promotion for missing value attributes' --- test/test.html | 14 ++++++++++++++ test/test.js | 26 +++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/test/test.html b/test/test.html index c0018b31..b66dbf6a 100644 --- a/test/test.html +++ b/test/test.html @@ -75,6 +75,20 @@ + + +
+ + + +
diff --git a/test/test.js b/test/test.js index 2f94ae55..c76ec4c3 100644 --- a/test/test.js +++ b/test/test.js @@ -46,10 +46,26 @@ describe('form', function() { }); it('formToArray: semantic test', function() { - var formData = $('#form2').formToArray(true); - var testData = ['a','b','c','d','e','f']; - for (var i=0; i < 6; i++) { - assert.strictEqual(formData[i].name, testData[i], 'match value at index=' + i); - } + var formData = $('#form2').formToArray(true); + var testData = ['a','b','c','d','e','f']; + for (var i=0; i < 6; i++) { + assert.strictEqual(formData[i].name, testData[i], 'match value at index=' + i); + } + }); + + it('formToArray: text promotion for missing value attributes', function() { + var expected = [ + { name: 'A', value: ''}, + { name: 'B', value: 'MISSING_ATTR'}, + { name: 'C', value: ''}, + { name: 'C', value: 'MISSING_ATTR'} + ]; + var a = $('#form6').formToArray(true); + + // verify all the option values + for (var i=0; i < a.length; i++) { + assert.strictEqual(a[i].name, expected[i].name, 'Name: ' + a[i].name + ' = ' + expected[i].name); + assert.strictEqual(a[i].value, expected[i].value, 'Value: ' + a[i].value + ' = ' + expected[i].value); + } }); }); From 76c7c90fa102ae1e4ed764ea6a6c574913210f64 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 6 Mar 2017 20:46:18 -0500 Subject: [PATCH 003/108] Outside fields bug fix Resolves #461 In non-IE browsers outside fields are already included in elements attribute of form, so there is no need to add outside fields again. Courtesy of @FinesseRus --- src/jquery.form.js | 3 ++- test/test.html | 6 ++++++ test/test.js | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/jquery.form.js b/src/jquery.form.js index 48e5cfa0..edd1d27a 100644 --- a/src/jquery.form.js +++ b/src/jquery.form.js @@ -1002,7 +1002,8 @@ } // #386; account for inputs outside the form which use the 'form' attribute - if ( formId ) { + // FinesseRus: in non-IE browsers outside fields are already included in form.elements. + if (formId && (semantic || /(Edge|Trident)\//.test(navigator.userAgent))) { els2 = $(':input[form="' + formId + '"]').get(); // hat tip @thet if ( els2.length ) { els = (els || []).concat(els2); diff --git a/test/test.html b/test/test.html index b66dbf6a..ea3478c1 100644 --- a/test/test.html +++ b/test/test.html @@ -89,6 +89,12 @@ + + +
+ +
+ diff --git a/test/test.js b/test/test.js index c76ec4c3..3be00f77 100644 --- a/test/test.js +++ b/test/test.js @@ -68,4 +68,9 @@ describe('form', function() { assert.strictEqual(a[i].value, expected[i].value, 'Value: ' + a[i].value + ' = ' + expected[i].value); } }); + + it('formToArray: outside fields', function() { + var formData = $('#form8').formToArray(); + assert.strictEqual(formData.length, 2, 'There are two "successful" elements of the form'); + }); }); From 60d99a910e2c3c769037266e9991e46954319524 Mon Sep 17 00:00:00 2001 From: emasab Date: Tue, 7 Mar 2017 19:16:57 +0100 Subject: [PATCH 004/108] IE fix if form is in a different document (#518) * IE fix if form is in a different document if form is in a different document than jquery Resolves #258 --- src/jquery.form.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/jquery.form.js b/src/jquery.form.js index edd1d27a..0ed9e72f 100644 --- a/src/jquery.form.js +++ b/src/jquery.form.js @@ -407,8 +407,10 @@ s = $.extend(true, {}, $.ajaxSettings, options); s.context = s.context || s; id = 'jqFormIO' + (new Date().getTime()); + var ownerDocument = form.ownerDocument; + var $body = $form.closest('body'); if (s.iframeTarget) { - $io = $(s.iframeTarget); + $io = $(s.iframeTarget, ownerDocument); n = $io.attr2('name'); if (!n) { $io.attr2('name', id); @@ -418,7 +420,7 @@ } } else { - $io = $('