File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed
packages/babel-plugin-transform-jsx-to-tagged-templates/src Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -53,8 +53,6 @@ export default function jsxToTaggedTemplatesBabelPlugin({ types: t }, options =
5353 const open = node . openingElement ;
5454 const { name } = open . name ;
5555
56- const toProcess = [ ] ;
57-
5856 if ( name . match ( / ^ [ A - Z ] / ) ) {
5957 raw ( '<' ) ;
6058 expr ( t . identifier ( name ) ) ;
@@ -90,21 +88,24 @@ export default function jsxToTaggedTemplatesBabelPlugin({ types: t }, options =
9088 }
9189 }
9290
93- const children = t . react . buildChildren ( node ) ;
94- if ( htmlOutput || children && children . length !== 0 ) {
91+ if ( htmlOutput || node . children && node . children . length !== 0 ) {
9592 raw ( '>' ) ;
96- for ( let i = 0 ; i < children . length ; i ++ ) {
97- let child = children [ i ] ;
98- if ( t . isStringLiteral ( child ) ) {
93+ for ( let i = 0 ; i < node . children . length ; i ++ ) {
94+ let child = node . children [ i ] ;
95+ if ( t . isJSXText ( child ) ) {
9996 // @todo - expose `whitespace: true` option?
100- raw ( child . value ) ;
101- }
102- else if ( t . isJSXElement ( child ) ) {
103- processNode ( child ) ;
97+ raw ( child . value . trim ( ) ) ;
10498 }
10599 else {
106- expr ( child ) ;
107- toProcess . push ( child ) ;
100+ if ( t . isJSXExpressionContainer ( child ) ) {
101+ child = child . expression ;
102+ }
103+ if ( t . isJSXElement ( child ) ) {
104+ processNode ( child ) ;
105+ }
106+ else {
107+ expr ( child ) ;
108+ }
108109 }
109110 }
110111
You can’t perform that action at this time.
0 commit comments