mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(core): eliminate top-level property access in ɵɵNgOnChangesFeature (#58297)
Top-level property access was causing dead code elimination (DCE) and tree-shaking issues. This commit modifies `ɵɵNgOnChangesFeature` to prevent these bailouts. PR Close #58297
This commit is contained in:
parent
cf7f8c7c03
commit
2d3a689660
4 changed files with 19 additions and 9 deletions
|
|
@ -36,9 +36,16 @@ import {DirectiveDef, DirectiveDefFeature} from '../interfaces/definition';
|
|||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵNgOnChangesFeature<T>(): DirectiveDefFeature {
|
||||
return NgOnChangesFeatureImpl;
|
||||
}
|
||||
export const ɵɵNgOnChangesFeature: () => DirectiveDefFeature = /* @__PURE__ */ (() => {
|
||||
const ɵɵNgOnChangesFeatureImpl = () => NgOnChangesFeatureImpl;
|
||||
|
||||
// This option ensures that the ngOnChanges lifecycle hook will be inherited
|
||||
// from superclasses (in InheritDefinitionFeature).
|
||||
/** @nocollapse */
|
||||
ɵɵNgOnChangesFeatureImpl.ngInherit = true;
|
||||
|
||||
return ɵɵNgOnChangesFeatureImpl;
|
||||
})();
|
||||
|
||||
export function NgOnChangesFeatureImpl<T>(definition: DirectiveDef<T>) {
|
||||
if (definition.type.prototype.ngOnChanges) {
|
||||
|
|
@ -47,12 +54,6 @@ export function NgOnChangesFeatureImpl<T>(definition: DirectiveDef<T>) {
|
|||
return rememberChangeHistoryAndInvokeOnChangesHook;
|
||||
}
|
||||
|
||||
// This option ensures that the ngOnChanges lifecycle hook will be inherited
|
||||
// from superclasses (in InheritDefinitionFeature).
|
||||
/** @nocollapse */
|
||||
// tslint:disable-next-line:no-toplevel-property-access
|
||||
(ɵɵNgOnChangesFeature as DirectiveDefFeature).ngInherit = true;
|
||||
|
||||
/**
|
||||
* This is a synthetic lifecycle hook which gets inserted into `TView.preOrderHooks` to simulate
|
||||
* `ngOnChanges`.
|
||||
|
|
|
|||
|
|
@ -434,6 +434,9 @@
|
|||
{
|
||||
"name": "NgModuleRef2"
|
||||
},
|
||||
{
|
||||
"name": "NgOnChangesFeatureImpl"
|
||||
},
|
||||
{
|
||||
"name": "NgZone"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -419,6 +419,9 @@
|
|||
{
|
||||
"name": "NgModuleRef2"
|
||||
},
|
||||
{
|
||||
"name": "NgOnChangesFeatureImpl"
|
||||
},
|
||||
{
|
||||
"name": "NgZone"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -455,6 +455,9 @@
|
|||
{
|
||||
"name": "NgModuleRef2"
|
||||
},
|
||||
{
|
||||
"name": "NgOnChangesFeatureImpl"
|
||||
},
|
||||
{
|
||||
"name": "NgZone"
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue