Skip to content

Commit 5367013

Browse files
authored
fix(material/schematics): add handling for several api changes (#25943)
* fix(material/schematics): add handling for several api changes * remove tickInterval, valueText, defaultColor, defaultTabIndex, onTouched, and displayValue for slider template migrations * fixup! fix(material/schematics): add handling for several api changes * fixup! fix(material/schematics): add handling for several api changes
1 parent 9a35ddf commit 5367013

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,40 @@ describe('slider template migrator', () => {
9797
);
9898
await runMigrationTest(
9999
`
100-
<mat-slider vertical invert></mat-slider>`,
100+
<mat-slider tickInterval="2"></mat-slider>`,
101101
`
102-
<!-- TODO: The 'vertical' property no longer exists -->
103-
<!-- TODO: The 'invert' property no longer exists -->
102+
<!-- TODO: The 'tickInterval' property no longer exists -->
103+
<mat-slider><input matSliderThumb /></mat-slider>`,
104+
);
105+
await runMigrationTest(
106+
`
107+
<mat-slider valueText></mat-slider>`,
108+
`
109+
<!-- TODO: The 'valueText' property no longer exists -->
104110
<mat-slider><input matSliderThumb /></mat-slider>`,
105111
);
106112
await runMigrationTest(
107113
`
108-
<button>Click Me</button><mat-slider vertical invert></mat-slider>`,
114+
<mat-slider
115+
vertical
116+
invert
117+
[valueText]="myValueText"
118+
tickInterval="4"></mat-slider>`,
109119
`
110-
<button>Click Me</button>
120+
<!-- TODO: The 'valueText' property no longer exists -->
111121
<!-- TODO: The 'vertical' property no longer exists -->
112122
<!-- TODO: The 'invert' property no longer exists -->
123+
<!-- TODO: The 'tickInterval' property no longer exists -->
124+
<mat-slider><input matSliderThumb /></mat-slider>`,
125+
);
126+
});
127+
128+
it('should remove displayValue and comment suggesting to switch to displayWith', async () => {
129+
await runMigrationTest(
130+
`
131+
<mat-slider [displayValue]="myDisplayValue"></mat-slider>`,
132+
`
133+
<!-- TODO: The 'displayValue' property no longer exists. Use 'displayWith' instead. -->
113134
<mat-slider><input matSliderThumb /></mat-slider>`,
114135
);
115136
});

src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,25 @@ export class SliderTemplateMigrator extends TemplateMigrator {
5252
updates.push(this._removeBinding(originalHtml, binding.node));
5353
}
5454

55-
if (binding.name === 'invert' || binding.name === 'vertical') {
55+
if (
56+
binding.name === 'invert' ||
57+
binding.name === 'vertical' ||
58+
binding.name === 'tickInterval' ||
59+
binding.name === 'valueText'
60+
) {
5661
// Remove the binding and leave a comment.
5762
comments.push(`<!-- TODO: The '${binding.name}' property no longer exists -->`);
5863
updates.push(this._removeBinding(originalHtml, binding.node));
5964
}
6065

66+
if (binding.name === 'displayValue') {
67+
// Remove the binding and leave a comment.
68+
comments.push(
69+
`<!-- TODO: The '${binding.name}' property no longer exists. Use 'displayWith' instead. -->`,
70+
);
71+
updates.push(this._removeBinding(originalHtml, binding.node));
72+
}
73+
6174
// TODO(wagnermaciel): Finish the remapping of other bindings.
6275
}
6376

0 commit comments

Comments
 (0)