fix(ngIf): don't create multiple elements when changing from a truthy to another thruthy value.

Fixes #4852.
This commit is contained in:
Tobias Bosch
2013-11-11 15:54:24 -08:00
parent 9577702e8d
commit 4612705ec2
2 changed files with 27 additions and 11 deletions

View File

@@ -28,6 +28,22 @@ describe('ngIf', function () {
expect(element.children().length).toBe(1);
});
it('should not add the element twice if the condition goes from true to true', function () {
$scope.hello = 'true1';
makeIf('hello');
expect(element.children().length).toBe(1);
$scope.$apply('hello = "true2"');
expect(element.children().length).toBe(1);
});
it('should not recreate the element if the condition goes from true to true', function () {
$scope.hello = 'true1';
makeIf('hello');
element.children().data('flag', true);
$scope.$apply('hello = "true2"');
expect(element.children().data('flag')).toBe(true);
});
it('should create then remove the element if condition changes', function () {
$scope.hello = true;
makeIf('hello');