Commit b31b9bd7 authored by Dave Methvin's avatar Dave Methvin Committed by John Resig

Add new html5 input types to list of serializable types. Older browers handle...

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.
parent 6bc222e7
var jsc = now(), var jsc = now(),
rscript = /<script(.|\s)*?\/script>/g, rscript = /<script(.|\s)*?\/script>/g,
rselectTextarea = /select|textarea/i, 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 = /=\?(&|$)/, jsre = /=\?(&|$)/,
rquery = /\?/, rquery = /\?/,
rts = /(\?|&)_=.*?(&|$)/, rts = /(\?|&)_=.*?(&|$)/,
......
...@@ -223,12 +223,18 @@ test("jQuery.ajax - dataType html", function() { ...@@ -223,12 +223,18 @@ test("jQuery.ajax - dataType html", function() {
test("serialize()", function() { test("serialize()", function() {
expect(5); 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(), 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'); 'Check form serialization as query string');
equals( jQuery('#form :input').serialize(), 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'); 'Check input serialization as query string');
equals( jQuery('#testForm').serialize(), equals( jQuery('#testForm').serialize(),
...@@ -240,14 +246,15 @@ test("serialize()", function() { ...@@ -240,14 +246,15 @@ test("serialize()", function() {
'Check input serialization as query string'); 'Check input serialization as query string');
equals( jQuery('#form, #testForm').serialize(), 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'); 'Multiple form serialization as query string');
/* Temporarily disabled. Opera 10 has problems with form serialization. /* Temporarily disabled. Opera 10 has problems with form serialization.
equals( jQuery('#form, #testForm :input').serialize(), 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'); 'Mixed form/input serialization as query string');
*/ */
jQuery("#html5email, #html5number").remove();
}); });
test("jQuery.param()", function() { test("jQuery.param()", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment