fix(ivy): Ensure ComponentFactory uses both injectors to retrieve rendererFactory (#27341)
PR Close #27341
This commit is contained in:
parent
6f5c124fe9
commit
7d89cff545
|
@ -115,15 +115,12 @@ export class ComponentFactory<T> extends viewEngine_ComponentFactory<T> {
|
||||||
ngModule?: viewEngine_NgModuleRef<any>|undefined): viewEngine_ComponentRef<T> {
|
ngModule?: viewEngine_NgModuleRef<any>|undefined): viewEngine_ComponentRef<T> {
|
||||||
const isInternalRootView = rootSelectorOrNode === undefined;
|
const isInternalRootView = rootSelectorOrNode === undefined;
|
||||||
|
|
||||||
let rendererFactory: RendererFactory3;
|
const rootViewInjector =
|
||||||
let sanitizer: Sanitizer|null = null;
|
ngModule ? createChainedInjector(injector, ngModule.injector) : injector;
|
||||||
|
|
||||||
if (ngModule) {
|
const rendererFactory =
|
||||||
rendererFactory = ngModule.injector.get(RendererFactory2) as RendererFactory3;
|
rootViewInjector.get(RendererFactory2, domRendererFactory3) as RendererFactory3;
|
||||||
sanitizer = ngModule.injector.get(Sanitizer, null);
|
const sanitizer = rootViewInjector.get(Sanitizer, null);
|
||||||
} else {
|
|
||||||
rendererFactory = domRendererFactory3;
|
|
||||||
}
|
|
||||||
|
|
||||||
const hostRNode = isInternalRootView ?
|
const hostRNode = isInternalRootView ?
|
||||||
elementCreate(this.selector, rendererFactory.createRenderer(null, this.componentDef)) :
|
elementCreate(this.selector, rendererFactory.createRenderer(null, this.componentDef)) :
|
||||||
|
@ -132,11 +129,9 @@ export class ComponentFactory<T> extends viewEngine_ComponentFactory<T> {
|
||||||
const rootFlags = this.componentDef.onPush ? LViewFlags.Dirty | LViewFlags.IsRoot :
|
const rootFlags = this.componentDef.onPush ? LViewFlags.Dirty | LViewFlags.IsRoot :
|
||||||
LViewFlags.CheckAlways | LViewFlags.IsRoot;
|
LViewFlags.CheckAlways | LViewFlags.IsRoot;
|
||||||
const rootContext: RootContext =
|
const rootContext: RootContext =
|
||||||
ngModule && !isInternalRootView ? ngModule.injector.get(ROOT_CONTEXT) : createRootContext();
|
!isInternalRootView ? rootViewInjector.get(ROOT_CONTEXT) : createRootContext();
|
||||||
|
|
||||||
const renderer = rendererFactory.createRenderer(hostRNode, this.componentDef);
|
const renderer = rendererFactory.createRenderer(hostRNode, this.componentDef);
|
||||||
const rootViewInjector =
|
|
||||||
ngModule ? createChainedInjector(injector, ngModule.injector) : injector;
|
|
||||||
|
|
||||||
if (rootSelectorOrNode && hostRNode) {
|
if (rootSelectorOrNode && hostRNode) {
|
||||||
ngDevMode && ngDevMode.rendererSetAttribute++;
|
ngDevMode && ngDevMode.rendererSetAttribute++;
|
||||||
|
|
Loading…
Reference in New Issue