Add new html5 input types to list of serializable types. Older browers handle these as type="text" so they should be consistently serialized on both old and new browsers. Fixes #5667.

This commit is contained in:
Dave Methvin 2009-12-17 10:02:58 +08:00 committed by John Resig
parent 6bc222e7a1
commit b31b9bd756
2 changed files with 12 additions and 5 deletions

View file

@ -1,7 +1,7 @@
var jsc = now(),
rscript = /<script(.|\s)*?\/script>/g,
rselectTextarea = /select|textarea/i,
rinput = /text|hidden|password|search/i,
rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
jsre = /=\?(&|$)/,
rquery = /\?/,
rts = /(\?|&)_=.*?(&|$)/,

View file

@ -223,12 +223,18 @@ test("jQuery.ajax - dataType html", function() {
test("serialize()", function() {
expect(5);
// Add html5 elements only for serialize because selector can't yet find them on non-html5 browsers
jQuery("#search").after(
'<input type="email" id="html5email" name="email" value="dave@jquery.com" />'+
'<input type="number" id="html5number" name="number" value="43" />'
);
equals( jQuery('#form').serialize(),
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2",
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2",
'Check form serialization as query string');
equals( jQuery('#form :input').serialize(),
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2",
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2",
'Check input serialization as query string');
equals( jQuery('#testForm').serialize(),
@ -240,14 +246,15 @@ test("serialize()", function() {
'Check input serialization as query string');
equals( jQuery('#form, #testForm').serialize(),
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
'Multiple form serialization as query string');
/* Temporarily disabled. Opera 10 has problems with form serialization.
equals( jQuery('#form, #testForm :input').serialize(),
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
'Mixed form/input serialization as query string');
*/
jQuery("#html5email, #html5number").remove();
});
test("jQuery.param()", function() {