Previously, when a downgraded component was destroyed in a way that did not trigger the `$destroy` event on the element (e.g. when a parent element was removed from the DOM by Angular, not AngularJS), the `ComponentRef` was not destroyed and unregistered. This commit fixes it by listening for the `$destroy` event on both the element and the scope. Fixes #22392 PR Close #22400
		
			
				
	
	
		
			24 lines
		
	
	
		
			796 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			796 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
/**
 | 
						|
 * @license
 | 
						|
 * Copyright Google Inc. All Rights Reserved.
 | 
						|
 *
 | 
						|
 * Use of this source code is governed by an MIT-style license that can be
 | 
						|
 * found in the LICENSE file at https://angular.io/license
 | 
						|
 */
 | 
						|
 | 
						|
import {UpgradeAdapterRef} from '@angular/upgrade';
 | 
						|
import * as angular from '@angular/upgrade/src/common/angular1';
 | 
						|
import {$ROOT_SCOPE} from '@angular/upgrade/src/common/constants';
 | 
						|
 | 
						|
export * from '../common/test_helpers';
 | 
						|
 | 
						|
export function $apply(adapter: UpgradeAdapterRef, exp: angular.Ng1Expression) {
 | 
						|
  const $rootScope = adapter.ng1Injector.get($ROOT_SCOPE) as angular.IRootScopeService;
 | 
						|
  $rootScope.$apply(exp);
 | 
						|
}
 | 
						|
 | 
						|
export function $digest(adapter: UpgradeAdapterRef) {
 | 
						|
  const $rootScope = adapter.ng1Injector.get($ROOT_SCOPE) as angular.IRootScopeService;
 | 
						|
  $rootScope.$digest();
 | 
						|
}
 |