File tree 3 files changed +15
-11
lines changed
packages/mui-material-nextjs/src/v13-pagesRouter
3 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 1
- import createCache from '@emotion/cache' ;
1
+ import createCache , { Options } from '@emotion/cache' ;
2
2
3
3
const isBrowser = typeof document !== 'undefined' ;
4
4
5
5
// On the client side, Create a meta tag at the top of the <head> and set it as insertionPoint.
6
6
// This assures that MUI styles are loaded first.
7
7
// It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
8
- export default function createEmotionCache ( ) {
8
+ export default function createEmotionCache ( options ?: Partial < Options > ) {
9
9
let insertionPoint ;
10
10
11
11
if ( isBrowser ) {
@@ -15,5 +15,5 @@ export default function createEmotionCache() {
15
15
insertionPoint = emotionInsertionPoint ?? undefined ;
16
16
}
17
17
18
- return createCache ( { key : 'mui' , insertionPoint } ) ;
18
+ return createCache ( { key : 'mui' , insertionPoint, ... options } ) ;
19
19
}
Original file line number Diff line number Diff line change 1
1
export * from './pagesRouterV13Document' ;
2
2
export * from './pagesRouterV13App' ;
3
+ export { default as createEmotionCache } from './createCache' ;
Original file line number Diff line number Diff line change @@ -102,14 +102,17 @@ export async function documentGetInitialProps(
102
102
const { styles } = extractCriticalToChunks ( initialProps . html ) ;
103
103
return {
104
104
...initialProps ,
105
- emotionStyleTags : styles . map ( ( style ) => (
106
- < style
107
- data-emotion = { `${ style . key } ${ style . ids . join ( ' ' ) } ` }
108
- key = { style . key }
109
- // eslint-disable-next-line react/no-danger
110
- dangerouslySetInnerHTML = { { __html : style . css } }
111
- />
112
- ) ) ,
105
+ emotionStyleTags : styles . map ( ( style ) =>
106
+ style . css . trim ( ) ? (
107
+ < style
108
+ data-emotion = { `${ style . key } ${ style . ids . join ( ' ' ) } ` }
109
+ key = { style . key }
110
+ // eslint-disable-next-line react/no-danger
111
+ dangerouslySetInnerHTML = { { __html : style . css } }
112
+ nonce = { cache . nonce }
113
+ />
114
+ ) : null ,
115
+ ) ,
113
116
} ;
114
117
} ,
115
118
} ,
You can’t perform that action at this time.
0 commit comments