This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +16
-3
lines changed
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -384,7 +384,7 @@ angularWidget('select', function(element){
384
384
if ( existingOption . id !== option . id ) {
385
385
lastElement . val ( existingOption . id = option . id ) ;
386
386
}
387
- if ( existingOption . selected !== option . selected ) {
387
+ if ( existingOption . element . selected !== option . selected ) {
388
388
lastElement . prop ( 'selected' , ( existingOption . selected = option . selected ) ) ;
389
389
}
390
390
} else {
Original file line number Diff line number Diff line change @@ -428,6 +428,21 @@ describe('select', function() {
428
428
expect ( select . val ( ) ) . toEqual ( '0' ) ;
429
429
expect ( select . find ( 'option' ) . length ) . toEqual ( 1 ) ;
430
430
} ) ;
431
+
432
+ it ( 'should select correct input if previously selected option was "?"' , function ( ) {
433
+ createSingleSelect ( ) ;
434
+ scope . values = [ { name :'A' } , { name :'B' } ] ;
435
+ scope . selected = { } ;
436
+ scope . $digest ( ) ;
437
+ expect ( select . find ( 'option' ) . length ) . toEqual ( 3 ) ;
438
+ expect ( select . val ( ) ) . toEqual ( '?' ) ;
439
+ expect ( select . find ( 'option' ) . eq ( 0 ) . val ( ) ) . toEqual ( '?' ) ;
440
+
441
+ browserTrigger ( select . find ( 'option' ) . eq ( 1 ) ) ;
442
+ expect ( select . val ( ) ) . toEqual ( '0' ) ;
443
+ expect ( select . find ( 'option' ) . eq ( 0 ) . prop ( 'selected' ) ) . toBeTruthy ( ) ;
444
+ expect ( select . find ( 'option' ) . length ) . toEqual ( 2 ) ;
445
+ } ) ;
431
446
} ) ;
432
447
433
448
describe ( 'on change' , function ( ) {
@@ -504,7 +519,5 @@ describe('select', function() {
504
519
expect ( scope . selected ) . toEqual ( [ scope . values [ 0 ] ] ) ;
505
520
} ) ;
506
521
} ) ;
507
-
508
522
} ) ;
509
-
510
523
} ) ;
You can’t perform that action at this time.
0 commit comments