File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,8 @@ var SelectController =
70
70
} ;
71
71
72
72
self . unselectEmptyOption = function ( ) {
73
- if ( self . emptyOption ) {
73
+ // Empty nodes with non-rendered ngIf can be comment nodes
74
+ if ( self . emptyOption && self . emptyOption [ 0 ] . nodeType === NODE_TYPE_ELEMENT ) {
74
75
self . emptyOption . removeAttr ( 'selected' ) ;
75
76
}
76
77
} ;
Original file line number Diff line number Diff line change @@ -2524,6 +2524,25 @@ describe('ngOptions', function() {
2524
2524
}
2525
2525
) ;
2526
2526
2527
+
2528
+ it ( 'should select the correct option after linking when the ngIf expression is initially falsy' , function ( ) {
2529
+ scope . values = [
2530
+ { name :'black' } ,
2531
+ { name :'white' } ,
2532
+ { name :'red' }
2533
+ ] ;
2534
+ scope . selected = scope . values [ 2 ] ;
2535
+
2536
+ expect ( function ( ) {
2537
+ createSingleSelect ( '<option ng-if="isBlank" value="">blank</option>' ) ;
2538
+ scope . $apply ( ) ;
2539
+ } ) . not . toThrow ( ) ;
2540
+
2541
+ expect ( element . find ( 'option' ) [ 2 ] ) . toBeMarkedAsSelected ( ) ;
2542
+ expect ( linkLog ) . toEqual ( [ 'linkNgOptions' ] ) ;
2543
+ } ) ;
2544
+
2545
+
2527
2546
it ( 'should not throw when a directive compiles the blank option before ngOptions is linked' , function ( ) {
2528
2547
expect ( function ( ) {
2529
2548
createSelect ( {
You can’t perform that action at this time.
0 commit comments