From 9b1aff905b638aa274a5fc8f88662df446d374bd Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 16 Mar 2012 09:41:00 -0700 Subject: feat(scope): broadcast $destroy event on scope destruction perf testing shows that in chrome this change adds 5-15% overhead when destroying 10k nested scopes where each scope has a $destroy listener --- test/service/scopeSpec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/service/scopeSpec.js b/test/service/scopeSpec.js index 95b028fe..972584cf 100644 --- a/test/service/scopeSpec.js +++ b/test/service/scopeSpec.js @@ -2,6 +2,9 @@ describe('Scope', function() { + beforeEach(module(provideLog)); + + describe('$root', function() { it('should point to itself', inject(function($rootScope) { expect($rootScope.$root).toEqual($rootScope); @@ -393,6 +396,15 @@ describe('Scope', function() { $rootScope.$digest(); expect(log).toEqual('12'); })); + + + it('should broadcast the $destroy event', inject(function($rootScope, log) { + first.$on('$destroy', log.fn('first')); + first.$new().$on('$destroy', log.fn('first-child')); + + first.$destroy(); + expect(log).toEqual('first; first-child'); + })); }); -- cgit v1.2.3