Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control flow schematic: multiple ngIf usages with the i18n attribute produces invalid code #53149

Closed
mattlewis92 opened this issue Nov 24, 2023 · 2 comments
Assignees
Labels
area: migrations Issues related to `ng update` migrations core: control flow Issues related to the built-in control flow (@if, @for, @switch)
Milestone

Comments

@mattlewis92
Copy link
Contributor

mattlewis92 commented Nov 24, 2023

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

core

Is this a regression?

No

Description

Using the @angular/core:control-flow-migration schematic produces invalid code when using multiple ngIf's in the same template combined with the i18n attribute.

Input:

<ng-template *ngIf="false; else barTempl" i18n="@@foo">
  Foo
</ng-template>
<ng-template i18n="@@bar" #barTempl> Bar </ng-template>

<a *ngIf="true" i18n="@@bam">Bam</a>

Output:

@if (false) {
  <ng-container i18n="@@foo">
    Foo
  </ng-container>
} @else {
  #barTempl|
}
<ng-template i1@if (true) {
  8nTempl> Bar </ng-templ
  }ate>
  <a *ngIf="true" i18n="@@bam">Bam</a>

Please provide a link to a minimal reproduction of the bug

See above for a minimal test case

Please provide the exception or error you saw

N/A

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

Angular CLI: 17.0.3
Node: 18.17.1
Package Manager: pnpm 8.10.5
OS: darwin arm64

Angular: 17.0.4
... animations, common, compiler, compiler-cli, core, elements
... forms, language-service, localize, platform-browser
... platform-browser-dynamic, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.1
@angular-devkit/build-angular   17.0.3
@angular-devkit/core            17.0.3
@angular-devkit/schematics      17.0.3
@angular/cdk                    17.0.1
@angular/cli                    17.0.3
@angular/google-maps            15.2.9
@schematics/angular             17.0.3
ng-packagr                      17.0.2
rxjs                            7.8.0
typescript                      5.2.2
webpack                         5.88.2
zone.js                         0.14.2


### Anything else?

Thank you for providing the control flow migration schematic, it's really helpful!
@pkozlowski-opensource pkozlowski-opensource added area: migrations Issues related to `ng update` migrations core: control flow Issues related to the built-in control flow (@if, @for, @switch) labels Nov 27, 2023
@ngbot ngbot bot added this to the needsTriage milestone Nov 27, 2023
@jessicajaniuk jessicajaniuk self-assigned this Nov 27, 2023
@jessicajaniuk
Copy link
Contributor

@mattlewis92 Thanks for this report! I've been able to replicate it with your example. I'll hopefully have a fix up soon.

jessicajaniuk pushed a commit to jessicajaniuk/angular that referenced this issue Nov 27, 2023
jessicajaniuk pushed a commit to jessicajaniuk/angular that referenced this issue Nov 27, 2023
This addresses an issue where multiple ng-templates are present with i18n attributes. The offsets would be incorrectly accounted for when being replaced with an ng-container.

fixes: angular#53149
jessicajaniuk pushed a commit to jessicajaniuk/angular that referenced this issue Nov 27, 2023
This addresses an issue where multiple ng-templates are present with i18n attributes. The offsets would be incorrectly accounted for when being replaced with an ng-container.

fixes: angular#53149
jessicajaniuk pushed a commit to jessicajaniuk/angular that referenced this issue Nov 28, 2023
This addresses an issue where multiple ng-templates are present with i18n attributes. The offsets would be incorrectly accounted for when being replaced with an ng-container.

fixes: angular#53149
pkozlowski-opensource pushed a commit that referenced this issue Nov 28, 2023
This addresses an issue where multiple ng-templates are present with i18n attributes. The offsets would be incorrectly accounted for when being replaced with an ng-container.

fixes: #53149

PR Close #53212
Tweniee pushed a commit to Tweniee/angular that referenced this issue Nov 29, 2023
…#53212)

This addresses an issue where multiple ng-templates are present with i18n attributes. The offsets would be incorrectly accounted for when being replaced with an ng-container.

fixes: angular#53149

PR Close angular#53212
tbondwilkinson pushed a commit to tbondwilkinson/angular that referenced this issue Dec 6, 2023
…#53212)

This addresses an issue where multiple ng-templates are present with i18n attributes. The offsets would be incorrectly accounted for when being replaced with an ng-container.

fixes: angular#53149

PR Close angular#53212
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 29, 2023
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this issue Jan 23, 2024
…#53212)

This addresses an issue where multiple ng-templates are present with i18n attributes. The offsets would be incorrectly accounted for when being replaced with an ng-container.

fixes: angular#53149

PR Close angular#53212
rlmestre pushed a commit to rlmestre/angular that referenced this issue Jan 26, 2024
…#53212)

This addresses an issue where multiple ng-templates are present with i18n attributes. The offsets would be incorrectly accounted for when being replaced with an ng-container.

fixes: angular#53149

PR Close angular#53212
amilamen pushed a commit to amilamen/angular that referenced this issue Jan 26, 2024
…#53212)

This addresses an issue where multiple ng-templates are present with i18n attributes. The offsets would be incorrectly accounted for when being replaced with an ng-container.

fixes: angular#53149

PR Close angular#53212
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: migrations Issues related to `ng update` migrations core: control flow Issues related to the built-in control flow (@if, @for, @switch)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants