Repository navigation
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimecore: hydrationstate: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core, platform-browser
Is this a regression?
No
Description
When an i18n tag is placed on an Angular component that has multiple elements inside it, hydration throws an error.
For example:
@Component({
selector: 'app-text',
template: '<ng-content></ng-content>',
standalone: true,
})
export class TextComponent {}
@Component({
selector: 'app-root',
standalone: true,
imports: [CommonModule, RouterOutlet, TextComponent],
template: `
<app-text i18n>
Before
<br />
After
</app-text>
`,
styleUrls: ['./app.component.css'],
})
export class AppComponent {}A runtime error is thrown (e.hasAttribute is not a function) during hydration.
In dev mode, this error is thrown as
ASSERTION ERROR: expected matching nodeType [Expected=> 3 == 1 <=Actual]
Please provide a link to a minimal reproduction of the bug
Please provide the exception or error you saw
In dev mode:
ASSERTION ERROR: expected matching nodeType [Expected=> 3 == 1 <=Actual]
### Please provide the environment you discovered this bug in (run `ng version`)
```true
Angular CLI: 18.0.2
Node: 18.20.3
Package Manager: yarn 1.22.19
OS: darwin arm64
Angular: 18.0.1
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic
... platform-server, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1800.2
@angular-devkit/build-angular 18.0.2
@angular-devkit/core 18.0.2
@angular-devkit/schematics 18.0.2
@angular/cli 18.0.2
@angular/ssr 18.0.2
@schematics/angular 18.0.2
rxjs 7.8.1
typescript 5.4.5
zone.js 0.14.6
Anything else?
Might be related to content projection on the Angular component, as this doesn't occur when nesting plain HTML elements, ie. this works:
<p i18n>
Before
<b/>
After
</p>
It also works with ng-container.
Thanks!
Reacted by Tomas Trajan and Lars Rye Jeppesen
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimecore: hydrationstate: has PR
Activity
tomastrajan commentedon May 30, 2024
Encountered the same thing today, would be really great if solved 🙏
AndrewKushnir commentedon Jun 20, 2024
Quick update: the fix for this issue was merged and will be available on NPM after the next Angular release (most likely v18.0.5).
tomastrajan commentedon Jun 21, 2024
@AndrewKushnir thank you !
henry-alakazhang commentedon Jun 25, 2024
I built the changes locally and tested it against my repo - everything seems to work. Thanks!
angular-automatic-lock-bot commentedon Jul 26, 2024
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.