@@ -895,10 +895,11 @@ test('jsx', async (t) => {
895
895
[
896
896
'/*@jsxRuntime automatic @jsxImportSource react*/' ,
897
897
'function _createMdxContent(props) {' ,
898
- ' const _components = Object.assign( {' ,
898
+ ' const _components = {' ,
899
899
' em: "em",' ,
900
- ' p: "p"' ,
901
- ' }, props.components);' ,
900
+ ' p: "p",' ,
901
+ ' ...props.components' ,
902
+ ' };' ,
902
903
' return <_components.p><_components.em>{"a"}</_components.em></_components.p>;' ,
903
904
'}' ,
904
905
'function MDXContent(props = {}) {' ,
@@ -978,9 +979,10 @@ test('jsx', async (t) => {
978
979
[
979
980
'/*@jsxRuntime automatic @jsxImportSource react*/' ,
980
981
'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"];' ,
984
986
' return <>{<_component0></_component0>}</>;' ,
985
987
'}' ,
986
988
'function MDXContent(props = {}) {' ,
@@ -999,9 +1001,10 @@ test('jsx', async (t) => {
999
1001
[
1000
1002
'/*@jsxRuntime automatic @jsxImportSource react*/' ,
1001
1003
'function _createMdxContent(props) {' ,
1002
- ' const _components = Object.assign({' ,
1003
- ' p: "p"' ,
1004
- ' }, props.components);' ,
1004
+ ' const _components = {' ,
1005
+ ' p: "p",' ,
1006
+ ' ...props.components' ,
1007
+ ' };' ,
1005
1008
' return <_components.p>{"Hello "}{props.name}</_components.p>;' ,
1006
1009
'}' ,
1007
1010
'function MDXContent(props = {}) {' ,
@@ -1030,9 +1033,10 @@ test('jsx', async (t) => {
1030
1033
' return <section {...props} />;' ,
1031
1034
'};' ,
1032
1035
'function _createMdxContent(props) {' ,
1033
- ' const _components = Object.assign({' ,
1034
- ' p: "p"' ,
1035
- ' }, props.components);' ,
1036
+ ' const _components = {' ,
1037
+ ' p: "p",' ,
1038
+ ' ...props.components' ,
1039
+ ' };' ,
1036
1040
' return <_components.p>{"a"}</_components.p>;' ,
1037
1041
'}' ,
1038
1042
'function MDXContent(props = {}) {' ,
@@ -1045,6 +1049,42 @@ test('jsx', async (t) => {
1045
1049
}
1046
1050
)
1047
1051
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
+
1048
1088
await t . test ( 'should serialize double quotes in attribute values' , ( ) => {
1049
1089
assert . match (
1050
1090
String ( compileSync ( "{<w x='y \" z' />}" , { jsx : true } ) ) ,
0 commit comments