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
8e7ddeb6
Unverified
Commit
8e7ddeb6
authored
Nov 21, 2019
by
Joe Haddad
Committed by
GitHub
Nov 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure CSS Is Preloaded First (#9486)
* Ensure CSS Is Preloaded First * add test polyfills
parent
7ff95951
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
_document.tsx
packages/next/pages/_document.tsx
+1
-1
index.test.js
test/integration/css/test/index.test.js
+45
-0
No files found.
packages/next/pages/_document.tsx
View file @
8e7ddeb6
...
...
@@ -474,6 +474,7 @@ export class Head extends Component<
href=
{
canonicalBase
+
getAmpPath
(
ampPath
,
dangerousAsPath
)
}
/>
)
}
{
this
.
getCssLinks
()
}
{
page
!==
'/_error'
&&
(
<
link
rel=
"preload"
...
...
@@ -513,7 +514,6 @@ export class Head extends Component<
// (by default, style-loader injects at the bottom of <head />)
<
noscript
id=
"__next_css__DO_NOT_USE__"
/>
)
}
{
this
.
getCssLinks
()
}
{
styles
||
null
}
</>
)
}
...
...
test/integration/css/test/index.test.js
View file @
8e7ddeb6
...
...
@@ -21,6 +21,44 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 2
const
fixturesDir
=
join
(
__dirname
,
'..'
,
'fixtures'
)
if
(
!
Array
.
prototype
.
flat
)
{
// eslint-disable-next-line no-extend-native
Object
.
defineProperty
(
Array
.
prototype
,
'flat'
,
{
configurable
:
true
,
value
:
function
flat
()
{
var
depth
=
isNaN
(
arguments
[
0
])
?
1
:
Number
(
arguments
[
0
])
return
depth
?
Array
.
prototype
.
reduce
.
call
(
this
,
function
(
acc
,
cur
)
{
if
(
Array
.
isArray
(
cur
))
{
acc
.
push
.
apply
(
acc
,
flat
.
call
(
cur
,
depth
-
1
))
}
else
{
acc
.
push
(
cur
)
}
return
acc
},
[]
)
:
Array
.
prototype
.
slice
.
call
(
this
)
},
writable
:
true
,
})
}
if
(
!
Array
.
prototype
.
flatMap
)
{
// eslint-disable-next-line no-extend-native
Object
.
defineProperty
(
Array
.
prototype
,
'flatMap'
,
{
configurable
:
true
,
value
:
function
flatMap
()
{
return
Array
.
prototype
.
map
.
apply
(
this
,
arguments
).
flat
()
},
writable
:
true
,
})
}
describe
(
'CSS Support'
,
()
=>
{
describe
(
'Basic Global Support'
,
()
=>
{
const
appDir
=
join
(
fixturesDir
,
'single-global'
)
...
...
@@ -476,6 +514,13 @@ describe('CSS Support', () => {
const
cssSheet
=
$
(
'link[rel="stylesheet"]'
)
expect
(
cssSheet
.
length
).
toBe
(
1
)
expect
(
cssSheet
.
attr
(
'href'
)).
toMatch
(
/^
\/
_next
\/
static
\/
css
\/
.*
\.
css$/
)
/* ensure CSS preloaded first */
const
allPreloads
=
[].
slice
.
call
(
$
(
'link[rel="preload"]'
))
const
styleIndexes
=
allPreloads
.
flatMap
((
p
,
i
)
=>
p
.
attribs
.
as
===
'style'
?
i
:
[]
)
expect
(
styleIndexes
).
toEqual
([
0
])
})
})
...
...
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