Revert "fix(upgrade): properly destroy upgraded component elements and descendants (#26209)"

This reverts commit 912f3d186f. Revert is needed due to compilation failures due to this PR inside Google.
This commit is contained in:
Jason Aden
2018-10-10 14:44:52 -07:00
parent 912f3d186f
commit 7466a99dda
4 changed files with 11 additions and 310 deletions

View File

@ -214,29 +214,24 @@ export interface INgModelController {
$name: string;
}
function noNg(): never {
function noNg() {
throw new Error('AngularJS v1.x is not loaded!');
}
const noNgElement: typeof angular.element = () => noNg();
noNgElement.cleanData = noNg;
let angular: {
bootstrap: (e: Element, modules: (string | IInjectable)[], config?: IAngularBootstrapConfig) =>
IInjectorService,
module: (prefix: string, dependencies?: string[]) => IModule,
element: {
(e: string | Element | Document | IAugmentedJQuery): IAugmentedJQuery;
cleanData: (nodes: Node[] | NodeList) => void;
},
element: (e: string | Element | Document | IAugmentedJQuery) => IAugmentedJQuery,
version: {major: number},
resumeBootstrap: () => void,
getTestability: (e: Element) => ITestabilityService
} = {
} = <any>{
bootstrap: noNg,
module: noNg,
element: noNgElement,
version: undefined as any,
element: noNg,
version: undefined,
resumeBootstrap: noNg,
getTestability: noNg
};
@ -287,7 +282,6 @@ export const module: typeof angular.module = (prefix, dependencies?) =>
angular.module(prefix, dependencies);
export const element: typeof angular.element = e => angular.element(e);
element.cleanData = nodes => angular.element.cleanData(nodes);
export const resumeBootstrap: typeof angular.resumeBootstrap = () => angular.resumeBootstrap();

View File

@ -124,15 +124,7 @@ export class UpgradeHelper {
controllerInstance.$onDestroy();
}
$scope.$destroy();
// Clean the jQuery/jqLite data on the component+child elements.
// Equivelent to how jQuery/jqLite invoke `cleanData` on an Element (this.element)
// https://github.com/jquery/jquery/blob/e743cbd28553267f955f71ea7248377915613fd9/src/manipulation.js#L223
// https://github.com/angular/angular.js/blob/26ddc5f830f902a3d22f4b2aab70d86d4d688c82/src/jqLite.js#L306-L312
// `cleanData` will invoke the AngularJS `$destroy` DOM event
// https://github.com/angular/angular.js/blob/26ddc5f830f902a3d22f4b2aab70d86d4d688c82/src/Angular.js#L1911-L1924
angular.element.cleanData([this.element]);
angular.element.cleanData(this.element.querySelectorAll('*'));
this.$element.triggerHandler !('$destroy');
}
prepareTransclusion(): angular.ILinkFn|undefined {