Repository navigation
fix(core): resolve the tag name of dynamically created hosts - #71460
Open
aminesbdev wants to merge 1 commit into
Open
aminesbdev wants to merge 1 commit into
aminesbdev wants to merge 1 commit into
Conversation
aminesbdev
force-pushed
the
fix/core-host-tag-name-dynamic-host
branch
from
October 20, 2026 13:32
7292a01 to
56962e4
Compare
The host of a bootstrapped, routed or dynamically created component isn't declared in a template, so its TNode holds the `#host` placeholder instead of a tag name. `HOST_TAG_NAME` and `DebugElement.name` returned that placeholder as is. Both now read the tag name from the native element in that case, like host binding sanitization already does for this placeholder. Fixes angular#71459
aminesbdev
force-pushed
the
fix/core-host-tag-name-dynamic-host
branch
from
October 20, 2026 14:11
56962e4 to
8e4f628
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
HOST_TAG_NAMEreturns'#host'when the host isn't declared in a template: root components, components rendered by<router-outlet>,ViewContainerRef.createComponent,createComponent()(with or withouthostElementanddirectives), and hosts created byTestBed.createComponentandTestBed.createDirective. The token returnstNode.value, and the host TNode built inComponentFactoryalways holds theTNodeName.DynamicHostplaceholder.DebugElement.namehas the same problem: it returns'#host'for the root of every fixture and for components rendered by<router-outlet>,NgComponentOutletorViewContainerRef.createComponent, sofixture.debugElement.query((de) => de.name === 'app-home')doesn't find a routed component.Issue Number: Fixes #71459
What is the new behavior?
Both now go through a
getElementTagNamehelper inview_utils.ts: when the TNode holds the placeholder, it reads the tag name from the native element, likeresolveElementinsanitization.tsalready does for host bindings. I went withlocalNameso the value matches what a template gives: lowercase for HTML, original casing for SVG (foreignObject). It falls back totagNamefor renderers whose elements don't havelocalName. Elements declared in templates don't go through this branch, so nothing changes for them.The new tests in
di_spec.tscover a root component,skipSelffrom an element in a root component's template,ViewContainerRef.createComponentwith a host directive,createComponent()with ahostElementanddirectives, an SVG host andTestBed.createDirective. A test indebug_node_spec.tschecksDebugElement.nameon a fixture root and finds a component created through aViewContainerRefby name. All of them fail on main withExpected '#host' to be ....Does this PR introduce a breaking change?
Other information
One visible effect outside this repo: angular/components#30892 replaced
element.tagNamewithHOST_TAG_NAMEinMatChip. A chip created throughcreateComponentorViewContainerRef.createComponentgets a<mat-basic-chip>host (the first tag in its selector), so since that change it has been styled as a standard chip. With this fix it's a basic chip again, like it was before that PR.