Skip to content

Commit

Permalink
fix(migrations): Ensure control flow migration ignores new block syntax
Browse files Browse the repository at this point in the history
This fix ensures that the control flow migration does not encounter any problems when new block sytax already exists in a template.
  • Loading branch information
thePunderWoman committed Oct 26, 2023
1 parent f1a020b commit 7e3b325
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Expand Up @@ -101,7 +101,7 @@ export function migrateTemplate(template: string): {migrated: string|null, error
// Allows for ICUs to be parsed.
tokenizeExpansionForms: true,
// Explicitly disable blocks so that their characters are treated as plain text.
tokenizeBlocks: false,
tokenizeBlocks: true,
preserveLineEndings: true,
});

Expand Down
18 changes: 18 additions & 0 deletions packages/core/schematics/test/control_flow_migration_spec.ts
Expand Up @@ -2084,5 +2084,23 @@ describe('control flow migration', () => {

expect(content).toContain('template: `<div><span>shrug</span></div>`');
});

it('should do nothing with already present updated control flow', async () => {
writeFile('/comp.ts', `
import {Component} from '@angular/core';
import {NgIf} from '@angular/common';
@Component({
imports: [NgIf], template: \`<div>@if (toggle) {<span>shrug</span>}</div>\`
})
class Comp {
toggle = false;
}
`);

await runMigration();
const content = tree.readContent('/comp.ts');
expect(content).toContain('template: `<div>@if (toggle) {<span>shrug</span>}</div>`');
});
});
});

0 comments on commit 7e3b325

Please sign in to comment.