@@ -34,6 +34,7 @@ export default (): Rule => (host: Tree, context: SchematicContext) => {
3434 const changes = new Map < string , FileChange [ ] > ( ) ;
3535 const htmlFiles = update . templateFiles ;
3636 const sassFiles = update . sassFiles ;
37+ let applyComment = false ;
3738
3839 const applyChanges = ( ) => {
3940 for ( const [ path , change ] of changes . entries ( ) ) {
@@ -44,6 +45,7 @@ export default (): Rule => (host: Tree, context: SchematicContext) => {
4445 . forEach ( c => buffer = c . apply ( buffer ) ) ;
4546
4647 host . overwrite ( path , buffer ) ;
48+ applyComment = true ;
4749 }
4850 } ;
4951
@@ -55,7 +57,7 @@ export default (): Rule => (host: Tree, context: SchematicContext) => {
5557 }
5658 } ;
5759
58- const isEmptyOrSpaces = ( str ) => str === null || str === '' || str === '\n' || str . match ( / ^ * $ / ) !== null ;
60+ const isEmptyOrSpaces = ( str ) => str === null || str === '' || str === '\n' || str === '\r\n' || str . match ( / ^ [ \n \t ] * * $ / ) !== null ;
5961
6062 // Replace the tabsType input with tabsAligment
6163 for ( const path of htmlFiles ) {
@@ -151,7 +153,12 @@ export default (): Rule => (host: Tree, context: SchematicContext) => {
151153
152154 if ( tabHeader ) {
153155 const content = offset . file . content . substring ( tabHeader . sourceSpan . end . offset , offset . endTag . start ) ;
154- if ( ! isEmptyOrSpaces ( content ) ) {
156+ // Since igx-tab-item tag is common for old and new igx-tabs
157+ // Check whether igx-tab-content is already present!
158+ const tabContentTag = new RegExp ( String . raw `${ comp . panelItem } ` ) ;
159+ const hasTabContent = content . match ( tabContentTag ) ;
160+
161+ if ( ( ! hasTabContent || hasTabContent . length === 0 ) && ! isEmptyOrSpaces ( content ) ) {
155162 const tabPanel = `\n<${ comp . panelItem } ${ classAttrText } >${ content } </${ comp . panelItem } >\n` ;
156163 addChange ( offset . file . url , new FileChange ( tabHeader . sourceSpan . end . offset , tabPanel , content , 'replace' ) ) ;
157164 }
@@ -162,17 +169,19 @@ export default (): Rule => (host: Tree, context: SchematicContext) => {
162169 changes . clear ( ) ;
163170
164171 // Insert a comment indicating the change/replacement
165- findElementNodes ( parseFile ( host , path ) , comp . component ) .
166- map ( node => getSourceOffset ( node as Element ) ) .
167- forEach ( offset => {
168- const { startTag, file } = offset ;
169- // eslint-disable-next-line max-len
170- const commentText = `<!--NOTE: This component has been updated by Infragistics migration: v${ version } \nPlease check your template whether all bindings/event handlers are correct.-->\n` ;
171- addChange ( file . url , new FileChange ( startTag . start , commentText ) ) ;
172- } ) ;
172+ if ( applyComment ) {
173+ findElementNodes ( parseFile ( host , path ) , comp . component ) .
174+ map ( node => getSourceOffset ( node as Element ) ) .
175+ forEach ( offset => {
176+ const { startTag, file } = offset ;
177+ // eslint-disable-next-line max-len
178+ const commentText = `<!--NOTE: This component has been updated by Infragistics migration: v${ version } \nPlease check your template whether all bindings/event handlers are correct.-->\n` ;
179+ addChange ( file . url , new FileChange ( startTag . start , commentText ) ) ;
180+ } ) ;
173181
174- applyChanges ( ) ;
175- changes . clear ( ) ;
182+ applyChanges ( ) ;
183+ changes . clear ( ) ;
184+ }
176185 }
177186
178187 for ( const sassPath of sassFiles ) {
0 commit comments