Skip to content

Commit ca79d86

Browse files
committed
Made it so that search input elements are now serialized. Fixes bug jquery#4107.
1 parent 75a973d commit ca79d86

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/ajax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jQuery.fn.extend({
7171
.filter(function(){
7272
return this.name && !this.disabled &&
7373
(this.checked || /select|textarea/i.test(this.nodeName) ||
74-
/text|hidden|password/i.test(this.type));
74+
/text|hidden|password|search/i.test(this.type));
7575
})
7676
.map(function(i, elem){
7777
var val = jQuery(this).val();

test/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ <h2 id="userAgent"></h2>
6868
<input type="text" style="display:none;" name="foo[bar]" id="hidden2"/>
6969

7070
<input type="text" id="name" name="name" value="name" />
71+
<input type="search" id="search" name="search" value="search" />
7172

7273
<button id="button" name="button">Button</button>
7374

test/unit/ajax.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ test("serialize()", function() {
186186
expect(6);
187187

188188
equals( jQuery('#form').serialize(),
189-
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2",
189+
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2",
190190
'Check form serialization as query string');
191191

192192
equals( jQuery('#form :input').serialize(),
193-
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2",
193+
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2",
194194
'Check input serialization as query string');
195195

196196
equals( jQuery('#testForm').serialize(),
@@ -202,11 +202,11 @@ test("serialize()", function() {
202202
'Check input serialization as query string');
203203

204204
equals( jQuery('#form, #testForm').serialize(),
205-
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&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=",
205+
"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=",
206206
'Multiple form serialization as query string');
207207

208208
equals( jQuery('#form, #testForm :input').serialize(),
209-
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&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=",
209+
"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=",
210210
'Mixed form/input serialization as query string');
211211
});
212212

test/unit/selector.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ test("pseudo (:) selectors", function() {
316316
t( "Last Child", "p:last-child", ["sap"] );
317317
t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2","liveLink1","liveLink2"] );
318318
t( "Empty", "ul:empty", ["firstUL"] );
319-
t( "Enabled UI Element", "#form input:not([type=hidden]):enabled", ["text1","radio1","radio2","check1","check2","hidden2","name"] );
319+
t( "Enabled UI Element", "#form input:not([type=hidden]):enabled", ["text1","radio1","radio2","check1","check2","hidden2","name","search"] );
320320
t( "Disabled UI Element", "#form input:disabled", ["text2"] );
321321
t( "Checked UI Element", "#form input:checked", ["radio2","check1"] );
322322
t( "Selected Option Element", "#form option:selected", ["option1a","option2d","option3b","option3c"] );
@@ -359,7 +359,7 @@ test("pseudo (:) selectors", function() {
359359
t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
360360
t( "Is Visible", "#form input:visible", [] );
361361
t( "Is Visible", "div:visible:not(.testrunner-toolbar):lt(2)", ["nothiddendiv", "nothiddendivchild"] );
362-
t( "Is Hidden", "#form input:hidden", ["text1","text2","radio1","radio2","check1","check2","hidden1","hidden2","name"] );
362+
t( "Is Hidden", "#form input:hidden", ["text1","text2","radio1","radio2","check1","check2","hidden1","hidden2","name","search"] );
363363
t( "Is Hidden", "#main:hidden", ["main"] );
364364
t( "Is Hidden", "#dl:hidden", ["dl"] );
365365

@@ -382,7 +382,7 @@ test("pseudo (:) selectors", function() {
382382
t( "Check element position", "#dl div:first > div:first", ["foo"] );
383383
t( "Check element position", "div#nothiddendiv:first > div:first", ["nothiddendivchild"] );
384384

385-
t( "Form element :input", "#form :input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3"] );
385+
t( "Form element :input", "#form :input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "search", "button", "area1", "select1", "select2", "select3"] );
386386
t( "Form element :radio", "#form :radio", ["radio1", "radio2"] );
387387
t( "Form element :checkbox", "#form :checkbox", ["check1", "check2"] );
388388
t( "Form element :text", "#form :text", ["text1", "text2", "hidden2", "name"] );

0 commit comments

Comments
 (0)