@@ -263,8 +263,8 @@ test('hast-util-to-estree', function (t) {
263
263
264
264
t . deepEqual (
265
265
toEstree ( h ( 'a' , [ '\n' , h ( 'b' ) , '\n' ] ) ) ,
266
- cleanEstree ( ac . parse ( '<a><b/></a>' ) ) ,
267
- 'should ignore inter-element whitespace'
266
+ cleanEstree ( ac . parse ( '<a>{"\\n"} <b/>{"\\n"} </a>' ) ) ,
267
+ 'should support inter-element whitespace'
268
268
)
269
269
270
270
t . deepEqual (
@@ -347,6 +347,29 @@ test('hast-util-to-estree', function (t) {
347
347
'should support SVG w/ an explicit `space`'
348
348
)
349
349
350
+ t . deepEqual (
351
+ toEstree ( {
352
+ type : 'element' ,
353
+ tagName : 'p' ,
354
+ children : [
355
+ {
356
+ type : 'element' ,
357
+ tagName : 'b' ,
358
+ children : [ { type : 'text' , value : 'a' } ]
359
+ } ,
360
+ { type : 'text' , value : ' ' } ,
361
+ {
362
+ type : 'element' ,
363
+ tagName : 'i' ,
364
+ children : [ { type : 'text' , value : 'b' } ]
365
+ } ,
366
+ { type : 'text' , value : '.' }
367
+ ]
368
+ } ) ,
369
+ cleanEstree ( ac . parse ( '<p><b>{"a"}</b>{" "}<i>{"b"}</i>{"."}</p>' ) ) ,
370
+ 'should support whitespace between elements'
371
+ )
372
+
350
373
t . deepEqual (
351
374
toEstree ( { type : 'mdxJsxTextElement' } ) ,
352
375
cleanEstree ( ac . parse ( '<></>' ) ) ,
@@ -547,7 +570,7 @@ test('integration (micromark-extension-mdxjs, mdast-util-mdx)', function (t) {
547
570
548
571
t . deepEqual (
549
572
transform ( '<x>\n - y\n</x>' ) ,
550
- '<><x><ul><li>{"y"}</li></ul></x></>;' ,
573
+ '<><x><ul>{"\\n"} <li>{"y"}</li>{"\\n"} </ul></x></>;' ,
551
574
'should transform children in MDX.js elements'
552
575
)
553
576
@@ -561,7 +584,7 @@ test('integration (micromark-extension-mdxjs, mdast-util-mdx)', function (t) {
561
584
transform (
562
585
'import x from "y"\nexport const name = "World"\n\n## Hello, {name}!'
563
586
) ,
564
- 'import x from "y";\nexport const name = "World";\n<><h2>{"Hello, "}{name}{"!"}</h2></>;' ,
587
+ 'import x from "y";\nexport const name = "World";\n<>{"\\n"} <h2>{"Hello, "}{name}{"!"}</h2></>;' ,
565
588
'should transform MDX.js ESM'
566
589
)
567
590
@@ -576,7 +599,7 @@ test('integration (micromark-extension-mdxjs, mdast-util-mdx)', function (t) {
576
599
'import x from "y"\nexport const name = "World"\n\n## Hello, {name}!' ,
577
600
true
578
601
) ,
579
- '<><h2>{"Hello, "}{}{"!"}</h2></>;' ,
602
+ '<>{"\\n"} <h2>{"Hello, "}{}{"!"}</h2></>;' ,
580
603
'should transform ESM w/o estrees'
581
604
)
582
605
@@ -674,7 +697,7 @@ test('integration (@babel/plugin-transform-react-jsx, react)', function (t) {
674
697
'export const name = "World";' ,
675
698
'' ,
676
699
'/*#__PURE__*/' ,
677
- 'React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("h2", null, "Hello, ", name, "!"));'
700
+ 'React.createElement(React.Fragment, null, "\\n", /*#__PURE__*/React.createElement("h2", null, "Hello, ", name, "!"));'
678
701
] . join ( '\n' ) ,
679
702
'should integrate w/ `@babel/plugin-transform-react-jsx` (MDX.js ESM)'
680
703
)
@@ -689,7 +712,7 @@ test('integration (@babel/plugin-transform-react-jsx, react)', function (t) {
689
712
'/*#__PURE__*/' ,
690
713
'_jsx(_Fragment, {' ,
691
714
' children: /*#__PURE__*/_jsxs("h1", {' ,
692
- ' children: ["Hi ", /*#__PURE__*/_jsx(Icon, {}), "!"]' ,
715
+ ' children: ["Hi ", /*#__PURE__*/_jsx(Icon, {}), " ", " !"]' ,
693
716
' })' ,
694
717
'});'
695
718
] . join ( '\n' ) ,
@@ -698,7 +721,7 @@ test('integration (@babel/plugin-transform-react-jsx, react)', function (t) {
698
721
699
722
t . deepEqual (
700
723
transform ( '# Hi <Icon /> {"!"}' , { pragma : 'a' , pragmaFrag : 'b' } ) ,
701
- 'a(b, null, a("h1", null, "Hi ", a(Icon, null), "!"));' ,
724
+ 'a(b, null, a("h1", null, "Hi ", a(Icon, null), " ", " !"));' ,
702
725
'should integrate w/ `@babel/plugin-transform-react-jsx` (pragma, pragmaFrag)'
703
726
)
704
727
@@ -777,7 +800,7 @@ test('integration (@vue/babel-plugin-jsx, Vue 3)', function (t) {
777
800
'import x from "y";' ,
778
801
'export const name = "World";' ,
779
802
'' ,
780
- '_createVNode(_Fragment, null, [_createVNode("h2", null, ["Hello, ", name, "!"])]);'
803
+ '_createVNode(_Fragment, null, ["\\n", _createVNode("h2", null, ["Hello, ", name, "!"])]);'
781
804
] . join ( '\n' ) ,
782
805
'should integrate w/ `@vue/babel-plugin-jsx` (MDX.js ESM)'
783
806
)
0 commit comments