Skip to content

i18n on disconnected content-projected nodes breaks hydration #57301

@henry-alakazhang

Description

@henry-alakazhang

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

Yes

Description

When tagging nodes with i18n, if the tagged element is projected using content projection, but disconnected from the DOM, hydration will break on the client side with this error:

ERROR Error: ASSERTION ERROR: Expected root i18n node during hydration [Expected=> null != null <=Actual]

Example code:

@Component({
  imports: [NgIf],
  selector: 'app-projected',
  template: `
    <ng-container *ngIf="false"> <!-- works if true -->
      <ng-content></ng-content>
    </ng-container>
  `,
  standalone: true,
})
export class ProjectedComponent {}
<app-projected>
  <div i18n>This content is not projected</div>
</app-projected>

The error also occurs if the i18n tag is on the component containing the content projection (in this case, app-projected)

Seems similar to #57105, in that there is no root node because the component can't/shouldn't be hydrated.

Please provide a link to a minimal reproduction of the bug

https://github.com/henry-alakazhang/angular-i18n-skiphydration-repro (last example)

Please provide the exception or error you saw

ERROR Error: ASSERTION ERROR: Expected root i18n node during hydration [Expected=> null != null <=Actual]

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 18.1.1
Node: 18.20.3
Package Manager: yarn 1.22.19
OS: darwin arm64

Angular: 18.1.1
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic
... platform-server, router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1801.1
@angular-devkit/build-angular   18.1.1
@angular-devkit/core            18.1.1
@angular-devkit/schematics      18.1.1
@schematics/angular             18.1.1
rxjs                            7.8.1
typescript                      5.5.4
zone.js                         0.14.8

Anything else?

No response

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: i18nIssues related to localization and internationalizationcore: hydrationstate: has PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions