@@ -225,26 +225,25 @@ jQuery.extend({
225
225
} ,
226
226
select : {
227
227
get : function ( elem ) {
228
- var value , i , max , option ,
229
- index = elem . selectedIndex ,
230
- values = [ ] ,
228
+ var value , option ,
231
229
options = elem . options ,
232
- one = elem . type === "select-one" ;
233
-
234
- // Nothing was selected
235
- if ( index < 0 ) {
236
- return null ;
237
- }
230
+ index = elem . selectedIndex ,
231
+ one = elem . type === "select-one" || index < 0 ,
232
+ values = one ? null : [ ] ,
233
+ max = one ? index + 1 : options . length ,
234
+ i = index < 0 ?
235
+ max :
236
+ one ? index : 0 ;
238
237
239
238
// Loop through all the selected options
240
- i = one ? index : 0 ;
241
- max = one ? index + 1 : options . length ;
242
239
for ( ; i < max ; i ++ ) {
243
240
option = options [ i ] ;
244
241
245
- // Don't return options that are disabled or in a disabled optgroup
246
- if ( option . selected && ( jQuery . support . optDisabled ? ! option . disabled : option . getAttribute ( "disabled" ) === null ) &&
247
- ( ! option . parentNode . disabled || ! jQuery . nodeName ( option . parentNode , "optgroup" ) ) ) {
242
+ // oldIE doesn't update selected after form reset (#2551)
243
+ if ( ( option . selected || i === index ) &&
244
+ // Don't return options that are disabled or in a disabled optgroup
245
+ ( jQuery . support . optDisabled ? ! option . disabled : option . getAttribute ( "disabled" ) === null ) &&
246
+ ( ! option . parentNode . disabled || ! jQuery . nodeName ( option . parentNode , "optgroup" ) ) ) {
248
247
249
248
// Get the specific value for the option
250
249
value = jQuery ( option ) . val ( ) ;
@@ -259,11 +258,6 @@ jQuery.extend({
259
258
}
260
259
}
261
260
262
- // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
263
- if ( one && ! values . length && options . length ) {
264
- return jQuery ( options [ index ] ) . val ( ) ;
265
- }
266
-
267
261
return values ;
268
262
} ,
269
263
0 commit comments