From: Dave Methvin Date: Thu, 17 Dec 2009 02:02:58 +0000 (+0800) Subject: Add new html5 input types to list of serializable types. Older browers handle these... X-Git-Tag: 1.4a2~16 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b31b9bd756a1489c3b1b856ed8b624c55da9e02f;p=jquery.git 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. --- diff --git a/src/ajax.js b/src/ajax.js index 5cc7b37e7..49c7df0a6 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -1,7 +1,7 @@ var jsc = now(), rscript = //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 = /(\?|&)_=.*?(&|$)/, diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 194fbd5f1..39d34093b 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -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( + ''+ + '' + ); + 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() {