File tree Expand file tree Collapse file tree 4 files changed +18
-9
lines changed
Expand file tree Collapse file tree 4 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -48,9 +48,15 @@ export function controllerKey(name: string): string {
4848 return '$' + name + 'Controller' ;
4949}
5050
51- // Destroy an AngularJS app given the app `$injector`.
52- //
53- // NOTE: Destroying an app is not officially supported by AngularJS, but we do our best.
51+ /**
52+ * Destroy an AngularJS app given the app `$injector`.
53+ *
54+ * NOTE: Destroying an app is not officially supported by AngularJS, but try to do our best by
55+ * destroying `$rootScope` and clean the jqLite/jQuery data on `$rootElement` and all
56+ * descendants.
57+ *
58+ * @param $injector The `$injector` of the AngularJS app to destroy.
59+ */
5460export function destroyApp ( $injector : IInjectorService ) : void {
5561 const $rootElement : IAugmentedJQuery = $injector . get ( $ROOT_ELEMENT ) ;
5662 const $rootScope : IRootScopeService = $injector . get ( $ROOT_SCOPE ) ;
Original file line number Diff line number Diff line change @@ -622,8 +622,9 @@ export class UpgradeAdapter {
622622
623623 // Destroy the AngularJS app once the Angular `PlatformRef` is destroyed.
624624 // This does not happen in a typical SPA scenario, but it might be useful for
625- // other usecases where desposing of an Angular/AngularJS app is necessary (such
626- // as Hot Module Replacement (HMR)).
625+ // other use-cases where disposing of an Angular/AngularJS app is necessary
626+ // (such as Hot Module Replacement (HMR)).
627+ // See https://github.com/angular/angular/issues/39935.
627628 platformRef . onDestroy ( ( ) => destroyApp ( ng1Injector ) ) ;
628629 } ) ;
629630 } )
Original file line number Diff line number Diff line change @@ -169,8 +169,9 @@ export function downgradeModule<T>(moduleFactoryOrBootstrapFn: NgModuleFactory<T
169169
170170 // Destroy the AngularJS app once the Angular `PlatformRef` is destroyed.
171171 // This does not happen in a typical SPA scenario, but it might be useful for
172- // other usecases where desposing of an Angular/AngularJS app is necessary (such
173- // as Hot Module Replacement (HMR)).
172+ // other use-cases where disposing of an Angular/AngularJS app is necessary
173+ // (such as Hot Module Replacement (HMR)).
174+ // See https://github.com/angular/angular/issues/39935.
174175 injector . get ( PlatformRef ) . onDestroy ( ( ) => destroyApp ( $injector ) ) ;
175176
176177 return injector ;
Original file line number Diff line number Diff line change @@ -259,8 +259,9 @@ export class UpgradeModule {
259259
260260 // Destroy the AngularJS app once the Angular `PlatformRef` is destroyed.
261261 // This does not happen in a typical SPA scenario, but it might be useful for
262- // other usecases where desposing of an Angular/AngularJS app is necessary (such
263- // as Hot Module Replacement (HMR)).
262+ // other use-cases where disposing of an Angular/AngularJS app is necessary
263+ // (such as Hot Module Replacement (HMR)).
264+ // See https://github.com/angular/angular/issues/39935.
264265 this . platformRef . onDestroy ( ( ) => destroyApp ( $injector ) ) ;
265266
266267 // Wire up the ng1 rootScope to run a digest cycle whenever the zone settles
You can’t perform that action at this time.
0 commit comments