diff --git a/CHANGELOG b/CHANGELOG index 60c8b56..d332c1d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Form#serializeElements should not serialize file inputs. (kangax, Lonesome Boy) + * Fix an issue with calling Event.pointer before the DOM is loaded. (kangax, jddalton) [#4 state:resolved] * Element#down on an input element should not raise error. (humeniuc, kangax) diff --git a/src/form.js b/src/form.js index 0fd2ef3..bb42428 100644 --- a/src/form.js +++ b/src/form.js @@ -12,7 +12,7 @@ var Form = { var data = elements.inject({ }, function(result, element) { if (!element.disabled && element.name) { key = element.name; value = $(element).getValue(); - if (value != null && (element.type != 'submit' || (!submitted && + if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted && submit !== false && (!submit || key == submit) && (submitted = true)))) { if (key in result) { // a key is already present; construct an array of values diff --git a/test/unit/fixtures/form.html b/test/unit/fixtures/form.html index 2259395..9ac9a0f 100644 --- a/test/unit/fixtures/form.html +++ b/test/unit/fixtures/form.html @@ -79,6 +79,10 @@ +
+ +
+
diff --git a/test/unit/form_test.js b/test/unit/form_test.js index ff4b5c9..1c12373 100644 --- a/test/unit/form_test.js +++ b/test/unit/form_test.js @@ -271,7 +271,9 @@ new Test.Unit.Runner({ $('form').serialize({ submit: false })); this.assertHashEqual({ val1:4, action:'blah' }, $('form').serialize({ submit: 'inexistent' })); - + + // file input should not be serialized + this.assertEqual('', $('form_with_file_input').serialize()); }, testFormMethodsOnExtendedElements: function() {