fix(select): do not throw when removing the element (e.g. via ngIf)

Fixes #15466

Closes #15468
This commit is contained in:
Georgios Kalpakas
2016-12-03 22:48:24 +02:00
parent 752b1e69b7
commit 7a667c77e3
2 changed files with 17 additions and 1 deletions
+2
View File
@@ -182,6 +182,8 @@ var SelectController =
updateScheduled = true;
$scope.$$postDigest(function() {
if ($scope.$$destroyed) return;
updateScheduled = false;
self.ngModelCtrl.$setViewValue(self.readValue());
if (renderAfter) self.ngModelCtrl.$render();
+15 -1
View File
@@ -7,7 +7,7 @@ describe('select', function() {
formElement = jqLite('<form name="form">' + html + '</form>');
element = formElement.find('select');
$compile(formElement)(scope);
scope.$apply();
scope.$digest();
}
function compileRepeatedOptions() {
@@ -767,6 +767,20 @@ describe('select', function() {
expect(element).toEqualSelect([unknownValue()], '1', '2', '3');
}
);
it('should not throw when removing the element and all its children', function() {
var template =
'<select ng-model="mySelect" ng-if="visible">' +
'<option value="">--- Select ---</option>' +
'</select>';
scope.visible = true;
compile(template);
// It should not throw when removing the element
scope.$apply('visible = false');
});
});