@@ -11,6 +11,8 @@ const { builders: b } = recast;
1111const HTML_ATTRIBUTES = [ 'class' , 'placeholder' , 'required' ] ;
1212const BUILT_IN_COMPONENTS = [ 'link-to' , 'input' , 'textarea' ] ;
1313
14+ let inAttr = false ;
15+
1416function isAttribute ( key ) {
1517 return HTML_ATTRIBUTES . includes ( key ) || isDataAttribute ( key ) ;
1618}
@@ -48,7 +50,7 @@ function transformTagName(tagName) {
4850 return char . toUpperCase ( ) ;
4951 }
5052
51- // Remove all occurances of '-'s from the tagName that aren't starting with `-`
53+ // Remove all occurrences of '-'s from the tagName that aren't starting with `-`
5254 return char === '-' ? '' : char . toLowerCase ( ) ;
5355 } ) ;
5456
@@ -299,7 +301,7 @@ function transformNode(node, fileInfo, config) {
299301 return ;
300302 }
301303
302- const newTagName = transformTagName ( tagName ) ;
304+ const newTagName = transformTagName ( tagName , inAttr ) ;
303305
304306 let attributes ;
305307 let children = node . program ? node . program . body : undefined ;
@@ -327,6 +329,9 @@ function transformNode(node, fileInfo, config) {
327329 ) ;
328330 return ;
329331 }
332+ if ( inAttr ) {
333+ return ;
334+ }
330335 attributes = transformNodeAttributes ( tagName , node ) ;
331336 }
332337 return b . element (
@@ -391,5 +396,13 @@ function transformToAngleBracket(_, fileInfo, config) {
391396 return transformNode ( node , fileInfo , config ) ;
392397 }
393398 } ,
399+ AttrNode : {
400+ enter ( ) {
401+ inAttr = true ;
402+ } ,
403+ exit ( ) {
404+ inAttr = false ;
405+ } ,
406+ } ,
394407 } ;
395408}
0 commit comments