@@ -895,10 +895,11 @@ test('jsx', async (t) => {
895895 [
896896 '/*@jsxRuntime automatic @jsxImportSource react*/' ,
897897 'function _createMdxContent(props) {' ,
898- ' const _components = Object.assign( {' ,
898+ ' const _components = {' ,
899899 ' em: "em",' ,
900- ' p: "p"' ,
901- ' }, props.components);' ,
900+ ' p: "p",' ,
901+ ' ...props.components' ,
902+ ' };' ,
902903 ' return <_components.p><_components.em>{"a"}</_components.em></_components.p>;' ,
903904 '}' ,
904905 'function MDXContent(props = {}) {' ,
@@ -978,9 +979,10 @@ test('jsx', async (t) => {
978979 [
979980 '/*@jsxRuntime automatic @jsxImportSource react*/' ,
980981 'function _createMdxContent(props) {' ,
981- ' const _components = Object.assign({' ,
982- ' "a-b": "a-b"' ,
983- ' }, props.components), _component0 = _components["a-b"];' ,
982+ ' const _components = {' ,
983+ ' "a-b": "a-b",' ,
984+ ' ...props.components' ,
985+ ' }, _component0 = _components["a-b"];' ,
984986 ' return <>{<_component0></_component0>}</>;' ,
985987 '}' ,
986988 'function MDXContent(props = {}) {' ,
@@ -999,9 +1001,10 @@ test('jsx', async (t) => {
9991001 [
10001002 '/*@jsxRuntime automatic @jsxImportSource react*/' ,
10011003 'function _createMdxContent(props) {' ,
1002- ' const _components = Object.assign({' ,
1003- ' p: "p"' ,
1004- ' }, props.components);' ,
1004+ ' const _components = {' ,
1005+ ' p: "p",' ,
1006+ ' ...props.components' ,
1007+ ' };' ,
10051008 ' return <_components.p>{"Hello "}{props.name}</_components.p>;' ,
10061009 '}' ,
10071010 'function MDXContent(props = {}) {' ,
@@ -1030,9 +1033,10 @@ test('jsx', async (t) => {
10301033 ' return <section {...props} />;' ,
10311034 '};' ,
10321035 'function _createMdxContent(props) {' ,
1033- ' const _components = Object.assign({' ,
1034- ' p: "p"' ,
1035- ' }, props.components);' ,
1036+ ' const _components = {' ,
1037+ ' p: "p",' ,
1038+ ' ...props.components' ,
1039+ ' };' ,
10361040 ' return <_components.p>{"a"}</_components.p>;' ,
10371041 '}' ,
10381042 'function MDXContent(props = {}) {' ,
@@ -1045,6 +1049,42 @@ test('jsx', async (t) => {
10451049 }
10461050 )
10471051
1052+ await t . test (
1053+ 'should combine passing `components` w/ props and a provider' ,
1054+ ( ) => {
1055+ assert . equal (
1056+ String (
1057+ compileSync ( 'a' , {
1058+ jsx : true ,
1059+ providerImportSource : '@mdx-js/react'
1060+ } )
1061+ ) ,
1062+ [
1063+ '/*@jsxRuntime automatic @jsxImportSource react*/' ,
1064+ 'import {useMDXComponents as _provideComponents} from "@mdx-js/react";' ,
1065+ 'function _createMdxContent(props) {' ,
1066+ ' const _components = {' ,
1067+ ' p: "p",' ,
1068+ ' ..._provideComponents(),' ,
1069+ ' ...props.components' ,
1070+ ' };' ,
1071+ ' return <_components.p>{"a"}</_components.p>;' ,
1072+ '}' ,
1073+ 'function MDXContent(props = {}) {' ,
1074+ ' const {wrapper: MDXLayout} = {' ,
1075+ ' ..._provideComponents(),' ,
1076+ ' ...props.components' ,
1077+ ' };' ,
1078+ ' return MDXLayout ? <MDXLayout {...props}><_createMdxContent {...props} /></MDXLayout> : _createMdxContent(props);' ,
1079+
1080+ '}' ,
1081+ 'export default MDXContent;' ,
1082+ ''
1083+ ] . join ( '\n' )
1084+ )
1085+ }
1086+ )
1087+
10481088 await t . test ( 'should serialize double quotes in attribute values' , ( ) => {
10491089 assert . match (
10501090 String ( compileSync ( "{<w x='y \" z' />}" , { jsx : true } ) ) ,
0 commit comments