fix(Scope): ensure that a scope is destroyed only once

Due to bd524fc4 calling $destroy() on a scope mupltiple times cases NPE.

Closes #1627
This commit is contained in:
Igor Minar
2012-11-30 01:16:08 +01:00
parent 5f7054bf5d
commit d6da505f4e
2 changed files with 20 additions and 1 deletions

View File

@@ -407,6 +407,22 @@ describe('Scope', function() {
first.$destroy();
expect(log).toEqual('first; first-child');
}));
it('should $destroy a scope only once and ignore any further destroy calls',
inject(function($rootScope) {
$rootScope.$digest();
expect(log).toBe('123');
first.$destroy();
first.$apply();
expect(log).toBe('12323');
first.$destroy();
first.$destroy();
first.$apply();
expect(log).toBe('1232323');
}));
});