Skip to content

Commit 76c7c90

Browse files
committed
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
1 parent 911efdf commit 76c7c90

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/jquery.form.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,8 @@
10021002
}
10031003

10041004
// #386; account for inputs outside the form which use the 'form' attribute
1005-
if ( formId ) {
1005+
// FinesseRus: in non-IE browsers outside fields are already included in form.elements.
1006+
if (formId && (semantic || /(Edge|Trident)\//.test(navigator.userAgent))) {
10061007
els2 = $(':input[form="' + formId + '"]').get(); // hat tip @thet
10071008
if ( els2.length ) {
10081009
els = (els || []).concat(els2);

test/test.html

+6
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@
8989
<option selected="selected">MISSING_ATTR</option>
9090
</select>
9191
</div></form>
92+
93+
<!-- form8, outside fields -->
94+
<form id="form8">
95+
<input type="text" name="insideForm">
96+
</form>
97+
<input type="text" name="outsideForm" form="form8">
9298
</div>
9399

94100

test/test.js

+5
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,9 @@ describe('form', function() {
6868
assert.strictEqual(a[i].value, expected[i].value, 'Value: ' + a[i].value + ' = ' + expected[i].value);
6969
}
7070
});
71+
72+
it('formToArray: outside fields', function() {
73+
var formData = $('#form8').formToArray();
74+
assert.strictEqual(formData.length, 2, 'There are two "successful" elements of the form');
75+
});
7176
});

0 commit comments

Comments
 (0)