@@ -40,6 +40,7 @@ export class SliderTemplateMigrator extends TemplateMigrator {
40
40
const originalHtml = node . sourceSpan . start . file . content ;
41
41
const bindings = this . _getBindings ( node ) ;
42
42
const inputBindings : string [ ] = [ ] ;
43
+ const comments : string [ ] = [ ] ;
43
44
44
45
for ( let i = 0 ; i < bindings . length ; i ++ ) {
45
46
const binding = bindings [ i ] ;
@@ -51,9 +52,19 @@ export class SliderTemplateMigrator extends TemplateMigrator {
51
52
updates . push ( this . _removeBinding ( originalHtml , binding . node ) ) ;
52
53
}
53
54
55
+ if ( binding . name === 'invert' || binding . name === 'vertical' ) {
56
+ // Remove the binding and leave a comment.
57
+ comments . push ( `<!-- TODO: The '${ binding . name } ' property no longer exists -->` ) ;
58
+ updates . push ( this . _removeBinding ( originalHtml , binding . node ) ) ;
59
+ }
60
+
54
61
// TODO(wagnermaciel): Finish the remapping of other bindings.
55
62
}
56
63
64
+ if ( comments . length ) {
65
+ updates . push ( this . _addComments ( node , comments ) ) ;
66
+ }
67
+
57
68
const matSliderThumb = inputBindings . length
58
69
? `<input matSliderThumb ${ inputBindings . join ( ' ' ) } />`
59
70
: '<input matSliderThumb />' ;
@@ -70,6 +81,37 @@ export class SliderTemplateMigrator extends TemplateMigrator {
70
81
return updates ;
71
82
}
72
83
84
+ /** Returns an update the adds the given comments before the given template ast element. */
85
+ private _addComments ( node : compiler . TmplAstElement , comments : string [ ] ) : Update {
86
+ const whitespace = this . _parseIndentation ( node ) ;
87
+ const indentation = '\n' + this . _parseIndentation ( node ) ;
88
+
89
+ // If everything leading up to the mat-slider start tag
90
+ // was whitespace, we don't need to start on a new line.
91
+ const commentStr =
92
+ whitespace . length === node . sourceSpan . start . col
93
+ ? comments . join ( indentation )
94
+ : indentation + comments . join ( indentation ) ;
95
+
96
+ return {
97
+ offset : node . sourceSpan . start . offset ,
98
+ updateFn : ( html : string ) =>
99
+ html . slice ( 0 , node . sourceSpan . start . offset ) +
100
+ commentStr +
101
+ `${ indentation } ${ html . slice ( node . sourceSpan . start . offset ) } ` ,
102
+ } ;
103
+ }
104
+
105
+ /** Returns the whitespace at the start of the given node's line. */
106
+ private _parseIndentation ( node : compiler . TmplAstElement ) : string {
107
+ const html = node . sourceSpan . start . file . content ;
108
+ const before = html . slice (
109
+ node . sourceSpan . start . offset - node . sourceSpan . start . col ,
110
+ node . sourceSpan . start . offset ,
111
+ ) ;
112
+ return before . slice ( 0 , before . length - before . trimStart ( ) . length ) ;
113
+ }
114
+
73
115
/** Returns an update that removes the given binding from the given template ast element. */
74
116
private _removeBinding ( originalHtml : string , binding : compiler . TmplAstNode ) : Update {
75
117
let charIndex = binding . sourceSpan . start . offset - 1 ;
0 commit comments