Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
d510758b
Unverified
Commit
d510758b
authored
Aug 11, 2022
by
Tim
Committed by
GitHub
Aug 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: ensure hidden iframe apps render in development mode (#39514)
parent
13a5eb22
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
fouc.ts
packages/next/client/dev/fouc.ts
+15
-3
No files found.
packages/next/client/dev/fouc.ts
View file @
d510758b
// This wrapper function is used to avoid raising a Trusted Types violation.
// This wrapper function is used to safely select the best available function
const
safeSetTimeout
=
(
callback
:
()
=>
void
)
=>
setTimeout
(
callback
)
// to schedule removal of the no-FOUC styles workaround. requestAnimationFrame
// is the ideal choice, but when used in iframes, there are no guarantees that
// the callback will actually be called, which could stall the promise returned
// from displayContent.
//
// See: https://www.vector-logic.com/blog/posts/on-request-animation-frame-and-embedded-iframes
const
safeCallbackQueue
=
(
callback
:
()
=>
void
)
=>
{
if
(
window
.
requestAnimationFrame
&&
window
.
self
===
window
.
top
)
{
window
.
requestAnimationFrame
(
callback
)
}
else
{
window
.
setTimeout
(
callback
)
}
}
// This function is used to remove Next.js' no-FOUC styles workaround for using
// This function is used to remove Next.js' no-FOUC styles workaround for using
// `style-loader` in development. It must be called before hydration, or else
// `style-loader` in development. It must be called before hydration, or else
// rendering won't have the correct computed values in effects.
// rendering won't have the correct computed values in effects.
export
function
displayContent
():
Promise
<
void
>
{
export
function
displayContent
():
Promise
<
void
>
{
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
((
resolve
)
=>
{
;(
window
.
requestAnimationFrame
||
safeSetTimeout
)
(
function
()
{
safeCallbackQueue
(
function
()
{
for
(
for
(
var
x
=
document
.
querySelectorAll
(
'[data-next-hide-fouc]'
),
var
x
=
document
.
querySelectorAll
(
'[data-next-hide-fouc]'
),
i
=
x
.
length
;
i
=
x
.
length
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment