This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -76,9 +76,11 @@ var SelectController =
76
76
}
77
77
} ;
78
78
79
+ var scopeDestroyed = false ;
79
80
$scope . $on ( '$destroy' , function ( ) {
80
81
// disable unknown option so that we don't do work when the whole select is being destroyed
81
82
self . renderUnknownOption = noop ;
83
+ scopeDestroyed = true ;
82
84
} ) ;
83
85
84
86
// Read the value of the select control, the implementation of this changes depending
@@ -182,6 +184,8 @@ var SelectController =
182
184
updateScheduled = true ;
183
185
184
186
$scope . $$postDigest ( function ( ) {
187
+ if ( scopeDestroyed ) return ;
188
+
185
189
updateScheduled = false ;
186
190
self . ngModelCtrl . $setViewValue ( self . readValue ( ) ) ;
187
191
if ( renderAfter ) self . ngModelCtrl . $render ( ) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ describe('select', function() {
7
7
formElement = jqLite ( '<form name="form">' + html + '</form>' ) ;
8
8
element = formElement . find ( 'select' ) ;
9
9
$compile ( formElement ) ( scope ) ;
10
- scope . $apply ( ) ;
10
+ scope . $digest ( ) ;
11
11
}
12
12
13
13
function compileRepeatedOptions ( ) {
@@ -767,6 +767,20 @@ describe('select', function() {
767
767
expect ( element ) . toEqualSelect ( [ unknownValue ( ) ] , '1' , '2' , '3' ) ;
768
768
}
769
769
) ;
770
+
771
+
772
+ it ( 'should not throw when removing the element and all its children' , function ( ) {
773
+ var template =
774
+ '<select ng-model="mySelect" ng-if="visible">' +
775
+ '<option value="">--- Select ---</option>' +
776
+ '</select>' ;
777
+ scope . visible = true ;
778
+
779
+ compile ( template ) ;
780
+
781
+ // It should not throw when removing the element
782
+ scope . $apply ( 'visible = false' ) ;
783
+ } ) ;
770
784
} ) ;
771
785
772
786
You can’t perform that action at this time.
0 commit comments