fix(migrations): prevent migrations from updating external templates multiple times (#44013)
The `NgComponentTemplateVisitor` helper was always referring back to the original source file on disk rather than the virtual file in the migration. This meant that some template migrations could attempt to modify the template multiple times resulting in invalid output. As an example the `migration-v13-router-link-empty-expression` migrates the following template: ``` <div [routerLink]></div> ``` to ``` <div [routerLink]="[]"></div> ``` But if the template was referenced multiple times in the program, such as when the component was referenced in the source and test entry-points, the migration would result in things like: ``` <div [routerLink]="[]"="[]"></div> ``` Fixes #44005. PR Close #44013
Showing
- packages/core/schematics/migrations/router-link-empty-expression/index.ts 1 addition, 1 deletion...hematics/migrations/router-link-empty-expression/index.ts
- packages/core/schematics/test/routerlink_empty_expr_migration_spec.ts 28 additions, 0 deletions...e/schematics/test/routerlink_empty_expr_migration_spec.ts
- packages/core/schematics/utils/ng_component_template.ts 14 additions, 8 deletionspackages/core/schematics/utils/ng_component_template.ts
Please register or sign in to comment