Skip to content

Commit

Permalink
fix test; refine document to have name
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding committed Mar 11, 2022
1 parent eb6f002 commit 4465c53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions packages/next/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,18 @@ export default class Document<P = {}> extends Component<DocumentProps & P> {

// Add a speical property to the built-in `Document` component so later we can
// identify if a user customized `Document` is used or not.
;(Document as any).__next_internal_document = () => (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
;(Document as any).__next_internal_document =
function InternalFunctionDocument() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}

export function Html(
props: React.DetailedHTMLProps<
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ export default abstract class Server {
if (opts.supportsDynamicHTML === true) {
const isBotRequest = isBot(req.headers['user-agent'] || '')
const isSupportedDocument =
!!(components.Document as any).__next_internal_document ||
(components.Document as any)?.__next_internal_document ||
typeof components.Document?.getInitialProps !== 'function'

// Disable dynamic HTML in cases that we know it won't be generated,
Expand Down

0 comments on commit 4465c53

Please sign in to comment.