Skip to content

i18n on disconnected content-projected nodes breaks hydration #57301

Closed

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

Activity

  1. added
    area: i18n
    on Aug 8, 2024
  2. added this to the needsTriage milestone on Aug 8, 2024
  3. self-assigned this
    on Aug 9, 2024
  4. added a commit that references this issue on Aug 13, 2024
    94744ae
  5. AndrewKushnir commented on Aug 13, 2024

    @AndrewKushnir
    Contributor

    @henry-alakazhang thanks for reporting the issue and providing a repro. I've created PR #57356 with the fix. The PR will go through code review and testing procedures and will be included into one of the upcoming releases.

  6. added
    P3
    on Aug 13, 2024
  7. modified the milestones: needsTriage, Backlog on Aug 13, 2024
  8. added a commit that references this issue on Aug 13, 2024
    de85979
  9. added a commit that references this issue on Aug 13, 2024
    822db64
  10. added a commit that references this issue on Aug 13, 2024
    84827d5
  11. added a commit that references this issue on Aug 30, 2024
    987dcf3
  12. angular-automatic-lock-bot commented on Sep 13, 2024

    @angular-automatic-lock-bot

    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.

  13. locked and limited conversation to collaborators on Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3area: i18ncore: hydrationstate: has PR

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions