Skip to content
Permalink
Browse files

Add new html5 input types to list of serializable types. Older brower…

…s handle these as type="text" so they should be consistently serialized on both old and new browsers. Fixes #5667.
  • Loading branch information
dmethvin authored and jeresig committed Dec 17, 2009
1 parent 6bc222e commit b31b9bd756a1489c3b1b856ed8b624c55da9e02f
Showing with 12 additions and 5 deletions.
  1. +1 −1 src/ajax.js
  2. +11 −4 test/unit/ajax.js
@@ -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 = /(\?|&)_=.*?(&|$)/,
@@ -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() {

2 comments on commit b31b9bd

@miketaylr

This comment has been minimized.

Copy link

miketaylr replied Dec 18, 2009

This is still missing type=datetime-local.

@jeresig

This comment has been minimized.

Copy link
Member

jeresig replied Dec 18, 2009

As mentioned in the ticket, it actually does take care of this since it checks for /datetime/ it'll match that - it would also match something bizarre like datetime-blah too.

Please sign in to comment.
You can’t perform that action at this time.