Skip to content

Commit

Permalink
fix(material/schematics): fix card tmpl migration
Browse files Browse the repository at this point in the history
  • Loading branch information
wagnermaciel committed Dec 2, 2022
1 parent 6f35599 commit 8a3cbc1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
Expand Up @@ -114,6 +114,32 @@ describe('card template migrator', () => {
></mat-card>
`,
);
await runMigrationTest(
`
<mat-card
[style.width]="na === 1 ? '90%' : '18rem'"
>
`,
`
<mat-card
appearance="outlined"
[style.width]="na === 1 ? '90%' : '18rem'"
>
`,
);
await runMigrationTest(
`
<mat-card
(click)="onClick()"
>
`,
`
<mat-card
appearance="outlined"
(click)="onClick()"
>
`,
);
});

it('should migrate inline templates', async () => {
Expand Down
Expand Up @@ -163,9 +163,9 @@ export function updateAttribute(
return `${prefix} ${attrText}${suffix}`;
}

const attr = node.attributes[0];
if (attr) {
const ctx = attr.sourceSpan.start.getContext(attr.sourceSpan.start.col + 1, 1)!;
const binding = node.attributes[0] ?? node.inputs[0] ?? node.outputs[0];
if (binding) {
const ctx = binding.sourceSpan.start.getContext(binding.sourceSpan.start.col + 1, 1)!;
const indentation = ctx.before;
return prefix + indentation + attrText + suffix;
}
Expand Down

0 comments on commit 8a3cbc1

Please sign in to comment.