Skip to content

fix(material/schematics): add handling for several api changes #25943

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

Merged
merged 3 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,40 @@ describe('slider template migrator', () => {
);
await runMigrationTest(
`
<mat-slider vertical invert></mat-slider>`,
<mat-slider tickInterval="2"></mat-slider>`,
`
<!-- TODO: The 'vertical' property no longer exists -->
<!-- TODO: The 'invert' property no longer exists -->
<!-- TODO: The 'tickInterval' property no longer exists -->
<mat-slider><input matSliderThumb /></mat-slider>`,
);
await runMigrationTest(
`
<mat-slider valueText></mat-slider>`,
`
<!-- TODO: The 'valueText' property no longer exists -->
<mat-slider><input matSliderThumb /></mat-slider>`,
);
await runMigrationTest(
`
<button>Click Me</button><mat-slider vertical invert></mat-slider>`,
<mat-slider
vertical
invert
[valueText]="myValueText"
tickInterval="4"></mat-slider>`,
`
<button>Click Me</button>
<!-- TODO: The 'valueText' property no longer exists -->
<!-- TODO: The 'vertical' property no longer exists -->
<!-- TODO: The 'invert' property no longer exists -->
<!-- TODO: The 'tickInterval' property no longer exists -->
<mat-slider><input matSliderThumb /></mat-slider>`,
);
});

it('should remove displayValue and comment suggesting to switch to displayWith', async () => {
await runMigrationTest(
`
<mat-slider [displayValue]="myDisplayValue"></mat-slider>`,
`
<!-- TODO: The 'displayValue' property no longer exists. Use 'displayWith' instead. -->
<mat-slider><input matSliderThumb /></mat-slider>`,
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,25 @@ export class SliderTemplateMigrator extends TemplateMigrator {
updates.push(this._removeBinding(originalHtml, binding.node));
}

if (binding.name === 'invert' || binding.name === 'vertical') {
if (
binding.name === 'invert' ||
binding.name === 'vertical' ||
binding.name === 'tickInterval' ||
binding.name === 'valueText'
) {
// Remove the binding and leave a comment.
comments.push(`<!-- TODO: The '${binding.name}' property no longer exists -->`);
updates.push(this._removeBinding(originalHtml, binding.node));
}

if (binding.name === 'displayValue') {
// Remove the binding and leave a comment.
comments.push(
`<!-- TODO: The '${binding.name}' property no longer exists. Use 'displayWith' instead. -->`,
);
updates.push(this._removeBinding(originalHtml, binding.node));
}

// TODO(wagnermaciel): Finish the remapping of other bindings.
}

Expand Down