From d99bb06af5033e358ce8974edcc28bacb7543491 Mon Sep 17 00:00:00 2001 From: Wagner Maciel Date: Tue, 8 Nov 2022 20:36:39 -0500 Subject: [PATCH 1/3] fix(material/schematics): add handling for several api changes * remove tickInterval, valueText, defaultColor, defaultTabIndex, onTouched, and displayValue for slider template migrations --- .../components/slider/slider-template.spec.ts | 59 ++++++++++++++++++- .../components/slider/slider-template.ts | 19 +++++- 2 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts b/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts index d8339810be04..473c9f1d9f9e 100644 --- a/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts +++ b/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts @@ -97,19 +97,74 @@ describe('slider template migrator', () => { ); await runMigrationTest( ` - `, + `, ` + + `, + ); + await runMigrationTest( + ` + `, + ` + + `, + ); + await runMigrationTest( + ` + `, + ` + + `, + ); + await runMigrationTest( + ` + `, + ` + + `, + ); + await runMigrationTest( + ` + `, + ` + + `, + ); + await runMigrationTest( + ` + `, + ` + + + + `, ); await runMigrationTest( ` - `, + `, ` + + + + `, ); }); diff --git a/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.ts b/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.ts index 702ac5f5aef3..f0e954aaf52c 100644 --- a/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.ts +++ b/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.ts @@ -52,12 +52,28 @@ 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' || + binding.name === 'defaultColor' || + binding.name === 'defaultTabIndex' || + binding.name === 'onTouched' + ) { // Remove the binding and leave a comment. comments.push(``); updates.push(this._removeBinding(originalHtml, binding.node)); } + if (binding.name === 'displayValue') { + // Remove the binding and leave a comment. + comments.push( + ``, + ); + updates.push(this._removeBinding(originalHtml, binding.node)); + } + // TODO(wagnermaciel): Finish the remapping of other bindings. } @@ -93,6 +109,7 @@ export class SliderTemplateMigrator extends TemplateMigrator { ? comments.join(indentation) : indentation + comments.join(indentation); + console.log(commentStr); return { offset: node.sourceSpan.start.offset, updateFn: (html: string) => From 0b70edd56cc56652f5e11ca7e2df209553e5260f Mon Sep 17 00:00:00 2001 From: Wagner Maciel Date: Wed, 9 Nov 2022 20:41:41 -0500 Subject: [PATCH 2/3] fixup! fix(material/schematics): add handling for several api changes --- .../components/slider/slider-template.spec.ts | 50 ++----------------- .../components/slider/slider-template.ts | 6 +-- 2 files changed, 4 insertions(+), 52 deletions(-) diff --git a/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts b/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts index 473c9f1d9f9e..9e6d26be33b8 100644 --- a/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts +++ b/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts @@ -97,7 +97,7 @@ describe('slider template migrator', () => { ); await runMigrationTest( ` - `, + `, ` `, @@ -109,62 +109,18 @@ describe('slider template migrator', () => { `, ); - await runMigrationTest( - ` - `, - ` - - `, - ); - await runMigrationTest( - ` - `, - ` - - `, - ); - await runMigrationTest( - ` - `, - ` - - `, - ); await runMigrationTest( ` `, + tickInterval="4">`, ` - - - - `, - ); - await runMigrationTest( - ` - `, - ` - - - - - - - + `, ); }); diff --git a/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.ts b/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.ts index f0e954aaf52c..a5e831998f81 100644 --- a/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.ts +++ b/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.ts @@ -56,10 +56,7 @@ export class SliderTemplateMigrator extends TemplateMigrator { binding.name === 'invert' || binding.name === 'vertical' || binding.name === 'tickInterval' || - binding.name === 'valueText' || - binding.name === 'defaultColor' || - binding.name === 'defaultTabIndex' || - binding.name === 'onTouched' + binding.name === 'valueText' ) { // Remove the binding and leave a comment. comments.push(``); @@ -109,7 +106,6 @@ export class SliderTemplateMigrator extends TemplateMigrator { ? comments.join(indentation) : indentation + comments.join(indentation); - console.log(commentStr); return { offset: node.sourceSpan.start.offset, updateFn: (html: string) => From 942c4814c1f8cc9d7a739423ac0cc98ff847ae51 Mon Sep 17 00:00:00 2001 From: Wagner Maciel Date: Wed, 9 Nov 2022 21:18:12 -0500 Subject: [PATCH 3/3] fixup! fix(material/schematics): add handling for several api changes --- .../rules/components/slider/slider-template.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts b/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts index 9e6d26be33b8..2b1bf17b7b2b 100644 --- a/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts +++ b/src/material/schematics/ng-generate/mdc-migration/rules/components/slider/slider-template.spec.ts @@ -124,4 +124,14 @@ describe('slider template migrator', () => { `, ); }); + + it('should remove displayValue and comment suggesting to switch to displayWith', async () => { + await runMigrationTest( + ` + `, + ` + + `, + ); + }); });