-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into fix-36435
- Loading branch information
Showing
39 changed files
with
789 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,5 @@ | |
"registry": "https://registry.npmjs.org/" | ||
} | ||
}, | ||
"version": "12.1.6-canary.7" | ||
"version": "12.1.6-canary.8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { createNext, FileRef } from 'e2e-utils' | ||
import { NextInstance } from 'test/lib/next-modes/base' | ||
import webdriver from 'next-webdriver' | ||
import path from 'path' | ||
|
||
const appDir = path.join(__dirname, 'material-ui') | ||
|
||
describe('New Link Behavior with material-ui', () => { | ||
let next: NextInstance | ||
|
||
beforeAll(async () => { | ||
next = await createNext({ | ||
files: { | ||
pages: new FileRef(path.join(appDir, 'pages')), | ||
src: new FileRef(path.join(appDir, 'src')), | ||
'next.config.js': new FileRef(path.join(appDir, 'next.config.js')), | ||
}, | ||
dependencies: { | ||
'@emotion/cache': 'latest', | ||
'@emotion/react': 'latest', | ||
'@emotion/server': 'latest', | ||
'@emotion/styled': 'latest', | ||
'@mui/icons-material': 'latest', | ||
'@mui/material': 'latest', | ||
next: 'latest', | ||
'prop-types': 'latest', | ||
react: 'latest', | ||
'react-dom': 'latest', | ||
eslint: 'latest', | ||
'eslint-config-next': 'latest', | ||
}, | ||
}) | ||
}) | ||
afterAll(() => next.destroy()) | ||
|
||
it('should render MuiLink with <a>', async () => { | ||
const browser = await webdriver(next.url, `/`) | ||
const element = await browser.elementByCss('a[href="/about"]') | ||
|
||
const color = await element.getComputedCss('color') | ||
expect(color).toBe('rgb(25, 133, 123)') | ||
|
||
const text = await element.text() | ||
expect(text).toBe('Go to the about page') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
reactStrictMode: true, | ||
experimental: { | ||
newNextLinkBehavior: true, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as React from 'react' | ||
import Head from 'next/head' | ||
import { ThemeProvider } from '@mui/material/styles' | ||
import CssBaseline from '@mui/material/CssBaseline' | ||
import { CacheProvider } from '@emotion/react' | ||
import theme from '../src/theme' | ||
import createEmotionCache from '../src/createEmotionCache' | ||
|
||
// Client-side cache, shared for the whole session of the user in the browser. | ||
const clientSideEmotionCache = createEmotionCache() | ||
|
||
export default function MyApp(props) { | ||
const { Component, emotionCache = clientSideEmotionCache, pageProps } = props | ||
|
||
return ( | ||
<CacheProvider value={emotionCache}> | ||
<Head> | ||
<meta name="viewport" content="initial-scale=1, width=device-width" /> | ||
</Head> | ||
<ThemeProvider theme={theme}> | ||
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */} | ||
<CssBaseline /> | ||
<Component {...pageProps} /> | ||
</ThemeProvider> | ||
</CacheProvider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import * as React from 'react' | ||
import Document, { Html, Head, Main, NextScript } from 'next/document' | ||
import createEmotionServer from '@emotion/server/create-instance' | ||
import theme from '../src/theme' | ||
import createEmotionCache from '../src/createEmotionCache' | ||
|
||
export default class MyDocument extends Document { | ||
render() { | ||
return ( | ||
<Html lang="en"> | ||
<Head> | ||
{/* PWA primary color */} | ||
<meta name="theme-color" content={theme.palette.primary.main} /> | ||
<link rel="shortcut icon" href="/static/favicon.ico" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" | ||
/> | ||
{/* Inject MUI styles first to match with the prepend: true configuration. */} | ||
{this.props.emotionStyleTags} | ||
</Head> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
) | ||
} | ||
} | ||
|
||
// `getInitialProps` belongs to `_document` (instead of `_app`), | ||
// it's compatible with static-site generation (SSG). | ||
MyDocument.getInitialProps = async (ctx) => { | ||
// Resolution order | ||
// | ||
// On the server: | ||
// 1. app.getInitialProps | ||
// 2. page.getInitialProps | ||
// 3. document.getInitialProps | ||
// 4. app.render | ||
// 5. page.render | ||
// 6. document.render | ||
// | ||
// On the server with error: | ||
// 1. document.getInitialProps | ||
// 2. app.render | ||
// 3. page.render | ||
// 4. document.render | ||
// | ||
// On the client | ||
// 1. app.getInitialProps | ||
// 2. page.getInitialProps | ||
// 3. app.render | ||
// 4. page.render | ||
|
||
const originalRenderPage = ctx.renderPage | ||
|
||
// You can consider sharing the same emotion cache between all the SSR requests to speed up performance. | ||
// However, be aware that it can have global side effects. | ||
const cache = createEmotionCache() | ||
const { extractCriticalToChunks } = createEmotionServer(cache) | ||
|
||
ctx.renderPage = () => | ||
originalRenderPage({ | ||
enhanceApp: (App) => | ||
function EnhanceApp(props) { | ||
return <App emotionCache={cache} {...props} /> | ||
}, | ||
}) | ||
|
||
const initialProps = await Document.getInitialProps(ctx) | ||
// This is important. It prevents emotion to render invalid HTML. | ||
// See https://github.com/mui/material-ui/issues/26561#issuecomment-855286153 | ||
const emotionStyles = extractCriticalToChunks(initialProps.html) | ||
const emotionStyleTags = emotionStyles.styles.map((style) => ( | ||
<style | ||
data-emotion={`${style.key} ${style.ids.join(' ')}`} | ||
key={style.key} | ||
// eslint-disable-next-line react/no-danger | ||
dangerouslySetInnerHTML={{ __html: style.css }} | ||
/> | ||
)) | ||
|
||
return { | ||
...initialProps, | ||
emotionStyleTags, | ||
} | ||
} |
Oops, something went wrong.