refactor(core): avoid code duplication in standalone-related logic (#45949)

This commit updates the standalone-related logic to address the feedback from previous code reviews (specifically: https://github.com/angular/angular/pull/45687#discussion_r854499586).

PR Close #45949
This commit is contained in:
Andrew Kushnir
2022-05-10 18:52:22 -07:00
committed by Jessica Janiuk
parent cd04588643
commit ca04ecedec
+3 -3
View File
@@ -288,6 +288,7 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
(typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode();
const type = componentDefinition.type;
const standalone = componentDefinition.standalone === true;
const declaredInputs: {[key: string]: string} = {} as any;
const def: Mutable<ComponentDef<any>, keyof ComponentDef<any>> = {
type: type,
@@ -309,9 +310,8 @@ export function ɵɵdefineComponent<T>(componentDefinition: {
onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush,
directiveDefs: null!, // assigned in noSideEffects
pipeDefs: null!, // assigned in noSideEffects
standalone: componentDefinition.standalone === true,
dependencies:
componentDefinition.standalone === true && componentDefinition.dependencies || null,
standalone,
dependencies: standalone && componentDefinition.dependencies || null,
getStandaloneInjector: null,
selectors: componentDefinition.selectors || EMPTY_ARRAY,
viewQuery: componentDefinition.viewQuery || null,