From 7bb312fcf612c57d6606ae14f21707f10d8ff9ce Mon Sep 17 00:00:00 2001
From: Jessica Janiuk
Date: Thu, 14 Dec 2023 15:58:59 -0500
Subject: [PATCH] fix(migrations): cf migration - stop removing empty newlines
from i18n blocks (#53578)
Since i18n sections are whitespace sensitive, we should avoid removing empty lines when inside an i18n block that were present before.
PR Close #53578
---
.../core/schematics/ng-generate/control-flow-migration/util.ts | 2 +-
packages/core/schematics/test/control_flow_migration_spec.ts | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/packages/core/schematics/ng-generate/control-flow-migration/util.ts b/packages/core/schematics/ng-generate/control-flow-migration/util.ts
index 48b52d149fac6..3302c0a81b9d9 100644
--- a/packages/core/schematics/ng-generate/control-flow-migration/util.ts
+++ b/packages/core/schematics/ng-generate/control-flow-migration/util.ts
@@ -628,7 +628,7 @@ export function formatTemplate(tmpl: string, templateType: string): string {
lineWasMigrated = true;
}
if ((line.trim() === '' && index !== 0 && index !== lines.length - 1) &&
- (inMigratedBlock || lineWasMigrated)) {
+ (inMigratedBlock || lineWasMigrated) && !inI18nBlock) {
// skip blank lines except if it's the first line or last line
// this preserves leading and trailing spaces if they are already present
continue;
diff --git a/packages/core/schematics/test/control_flow_migration_spec.ts b/packages/core/schematics/test/control_flow_migration_spec.ts
index cb4f5319110af..51be174024439 100644
--- a/packages/core/schematics/test/control_flow_migration_spec.ts
+++ b/packages/core/schematics/test/control_flow_migration_spec.ts
@@ -4729,6 +4729,7 @@ describe('control flow migration', () => {
`
`,
`Content here`,
``,
+ ` `,
` Else Content
`,
``,
``,
@@ -4745,6 +4746,7 @@ describe('control flow migration', () => {
` Content here`,
` } @else {`,
` `,
+ ` `,
` Else Content
`,
``,
` }`,