@@ -13,7 +13,7 @@ import {
1313import { IS_DART , isPresent , stringify } from 'angular2/src/facade/lang' ;
1414import { bootstrap } from 'angular2/platform/browser' ;
1515import { ApplicationRef } from 'angular2/src/core/application_ref' ;
16- import { Component , Directive , View , platform } from 'angular2/core' ;
16+ import { Component , Directive , View , OnDestroy , platform } from 'angular2/core' ;
1717import { BROWSER_PROVIDERS , BROWSER_APP_PROVIDERS } from 'angular2/platform/browser' ;
1818import { DOM } from 'angular2/src/core/dom/dom_adapter' ;
1919import { DOCUMENT } from 'angular2/render' ;
@@ -67,6 +67,15 @@ class HelloRootMissingTemplate {
6767class HelloRootDirectiveIsNotCmp {
6868}
6969
70+ @Component ( { selector : 'hello-app' } )
71+ @View ( { template : '' } )
72+ class HelloOnDestroyTickCmp implements OnDestroy {
73+ appRef : ApplicationRef ;
74+ constructor ( @Inject ( ApplicationRef ) appRef ) { this . appRef = appRef ; }
75+
76+ onDestroy ( ) : void { this . appRef . tick ( ) ; }
77+ }
78+
7079class _ArrayLogger {
7180 res : any [ ] = [ ] ;
7281 log ( s : any ) : void { this . res . push ( s ) ; }
@@ -163,6 +172,15 @@ export function main() {
163172 } ) ;
164173 } ) ) ;
165174
175+ it ( 'should not crash if change detection is invoked when the root component is disposed' ,
176+ inject ( [ AsyncTestCompleter ] , ( async ) => {
177+ bootstrap ( HelloOnDestroyTickCmp , testProviders )
178+ . then ( ( ref ) => {
179+ expect ( ( ) => ref . dispose ( ) ) . not . toThrow ( ) ;
180+ async . done ( ) ;
181+ } ) ;
182+ } ) ) ;
183+
166184 it ( 'should unregister change detectors when components are disposed' ,
167185 inject ( [ AsyncTestCompleter ] , ( async ) => {
168186 var app = platform ( BROWSER_PROVIDERS ) . application ( [ BROWSER_APP_PROVIDERS , testProviders ] ) ;
0 commit comments