Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(material/schematics): add template migration to schematic (#24563)
* create ComponentMigrator interface to store the different types of migrations for each component * refactor individual migrations to work with ComponentMigrator * add missing unit test for addAttribute * create TemplateMigrator to unify the interface for template migrations
- Loading branch information
1 parent
0108de5
commit 6feaaea
Showing
6 changed files
with
118 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/material/schematics/ng-generate/mdc-migration/rules/template-migrator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import * as compiler from '@angular/compiler'; | ||
|
||
export abstract class TemplateMigrator { | ||
/** The name of the component that this migration handles. */ | ||
abstract component: string; | ||
|
||
/** The tag name to be updated in the template. */ | ||
abstract tagName: string; | ||
|
||
/** | ||
* Updates the start tag of the given node in the html template. | ||
* | ||
* @param template The html content to be updated. | ||
* @param node The Element node to be updated. | ||
* @returns The updated template. | ||
*/ | ||
updateEndTag(template: string, node: compiler.TmplAstElement): string { | ||
return template; | ||
} | ||
|
||
/** | ||
* Updates the end tag of the given node in the html template. | ||
* | ||
* @param template The html content to be updated. | ||
* @param node The Element node to be updated. | ||
* @returns The updated template. | ||
*/ | ||
updateStartTag(template: string, node: compiler.TmplAstElement): string { | ||
return template; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters