diff --git a/packages/core/src/core_render3_private_export.ts b/packages/core/src/core_render3_private_export.ts index 268dbe0f33..dd6525fd34 100644 --- a/packages/core/src/core_render3_private_export.ts +++ b/packages/core/src/core_render3_private_export.ts @@ -145,7 +145,6 @@ export { ɵɵenableBindings, ɵɵFactoryDef, ɵɵgetCurrentView, - ɵɵgetFactoryOf, ɵɵgetInheritedFactory, ɵɵhostProperty, ɵɵi18n, diff --git a/packages/core/src/render3/di.ts b/packages/core/src/render3/di.ts index fa1f98e62e..1f92458ef1 100644 --- a/packages/core/src/render3/di.ts +++ b/packages/core/src/render3/di.ts @@ -698,40 +698,19 @@ export class NodeInjector implements Injector { } } -/** - * @codeGenApi - */ -export function ɵɵgetFactoryOf(type: Type): FactoryFn|null { - const typeAny = type as any; - - if (isForwardRef(type)) { - return (() => { - const factory = ɵɵgetFactoryOf(resolveForwardRef(typeAny)); - return factory ? factory() : null; - }) as any; - } - - let factory = getFactoryDef(typeAny); - if (factory === null) { - const injectorDef = getInjectorDef(typeAny); - factory = injectorDef && injectorDef.factory; - } - return factory || null; -} - /** * @codeGenApi */ export function ɵɵgetInheritedFactory(type: Type): (type: Type) => T { return noSideEffects(() => { const ownConstructor = type.prototype.constructor; - const ownFactory = ownConstructor[NG_FACTORY_DEF] || ɵɵgetFactoryOf(ownConstructor); + const ownFactory = ownConstructor[NG_FACTORY_DEF] || getFactoryOf(ownConstructor); const objectPrototype = Object.prototype; let parent = Object.getPrototypeOf(type.prototype).constructor; // Go up the prototype until we hit `Object`. while (parent && parent !== objectPrototype) { - const factory = parent[NG_FACTORY_DEF] || ɵɵgetFactoryOf(parent); + const factory = parent[NG_FACTORY_DEF] || getFactoryOf(parent); // If we hit something that has a factory and the factory isn't the same as the type, // we've found the inherited factory. Note the check that the factory isn't the type's @@ -752,3 +731,21 @@ export function ɵɵgetInheritedFactory(type: Type): (type: Type) => return t => new t(); }); } + +function getFactoryOf(type: Type): FactoryFn|null { + const typeAny = type as any; + + if (isForwardRef(type)) { + return (() => { + const factory = getFactoryOf(resolveForwardRef(typeAny)); + return factory ? factory() : null; + }) as any; + } + + let factory = getFactoryDef(typeAny); + if (factory === null) { + const injectorDef = getInjectorDef(typeAny); + factory = injectorDef && injectorDef.factory; + } + return factory || null; +} diff --git a/packages/core/src/render3/index.ts b/packages/core/src/render3/index.ts index 182961bac6..1d1322c36e 100644 --- a/packages/core/src/render3/index.ts +++ b/packages/core/src/render3/index.ts @@ -16,7 +16,7 @@ import {getComponent, getDirectives, getHostElement, getRenderedText} from './ut export {NgModuleType} from '../metadata/ng_module_def'; export {ComponentFactory, ComponentFactoryResolver, ComponentRef, injectComponentFactoryResolver} from './component_ref'; -export {ɵɵgetFactoryOf, ɵɵgetInheritedFactory} from './di'; +export {ɵɵgetInheritedFactory} from './di'; export {getLocaleId, setLocaleId} from './i18n/i18n_locale_id'; // clang-format off export { diff --git a/packages/core/test/bundling/forms/bundle.golden_symbols.json b/packages/core/test/bundling/forms/bundle.golden_symbols.json index dded841b47..b6ddd81b75 100644 --- a/packages/core/test/bundling/forms/bundle.golden_symbols.json +++ b/packages/core/test/bundling/forms/bundle.golden_symbols.json @@ -1004,6 +1004,9 @@ { "name": "getFactoryDef" }, + { + "name": "getFactoryOf" + }, { "name": "getFirstLContainer" }, @@ -1718,9 +1721,6 @@ { "name": "ɵɵelementStart" }, - { - "name": "ɵɵgetFactoryOf" - }, { "name": "ɵɵgetInheritedFactory" },