-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimestate: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
ComponentFactory.create code looks like calling the same function with the same parameters twice.
angular/packages/core/src/render3/component_ref.ts
Lines 166 to 174 in f70f50a
| const hostRenderer = rendererFactory.createRenderer(null, this.componentDef); | |
| // Determine a tag name used for creating host elements when this component is created | |
| // dynamically. Default to 'div' if this component did not specify any tag name in its selector. | |
| const elementName = this.componentDef.selectors[0][0] as string || 'div'; | |
| const hostRNode = rootSelectorOrNode ? | |
| locateHostElement(hostRenderer, rootSelectorOrNode, this.componentDef.encapsulation) : | |
| createElementNode( | |
| rendererFactory.createRenderer(null, this.componentDef), elementName, | |
| getNamespace(elementName)); |
First at line 166 the renderer is created and assigned to
hostRenderer, then in falsy branch of ternary assignment hostRNode = rootSelectorOrNode it gets created again and passed as first argument of createElementNode at line 173.
Even if Renderer2 implementations are usually smart enough to cache renderers, there's always a (IMHO) useless repetition of the call, thus an unneeded access to cache map.
Strange thing is that it gets referenced correctly as first argument of locateHostElement call for truthy branch.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run ng version)
No response
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimestate: has PR