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
937884b6
Unverified
Commit
937884b6
authored
Apr 27, 2020
by
Joe Haddad
Committed by
GitHub
Apr 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CSS Identifier Cleaning (#12239)
parent
04f3d94b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
11 deletions
+17
-11
getCssModuleLocalIdent.ts
...bpack/config/blocks/css/loaders/getCssModuleLocalIdent.ts
+5
-5
55css.module.css
...ixtures/catch-all-module/pages/[...post]/55css.module.css
+3
-0
index.js
...on/css-fixtures/catch-all-module/pages/[...post]/index.js
+3
-2
index.test.js
test/integration/css-modules/test/index.test.js
+5
-3
index.test.js
test/integration/scss-modules/test/index.test.js
+1
-1
No files found.
packages/next/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.ts
View file @
937884b6
...
@@ -43,11 +43,11 @@ export function getCssModuleLocalIdent(
...
@@ -43,11 +43,11 @@ export function getCssModuleLocalIdent(
/
\.
module_/
,
/
\.
module_/
,
'_'
'_'
)
)
// Replace
any characters not in the below set to prevent invalid
// Replace
invalid symbols with underscores instead of escaping
//
CSS character
s
//
https://mathiasbynens.be/notes/css-escapes#identifiers-string
s
.
replace
(
/
[^
a-zA-Z0-9-_
]
/g
,
'_'
)
.
replace
(
/
[^
a-zA-Z0-9-_
]
/g
,
'_'
)
//
CSS classes can also not start with a digit or a hyphen and then a
//
"they cannot start with a digit, two hyphens, or a hyphen followed by a digit [sic]"
//
digit
https://www.w3.org/TR/CSS21/syndata.html#characters
// https://www.w3.org/TR/CSS21/syndata.html#characters
.
replace
(
/^
(\d
|
_
\d
|__
)
/
,
'
'
)
.
replace
(
/^
(\d
|
--|-
\d)
/
,
'__$1
'
)
)
)
}
}
test/integration/css-fixtures/catch-all-module/pages/[...post]/55css.module.css
0 → 100644
View file @
937884b6
.home
{
color
:
green
;
}
test/integration/css-fixtures/catch-all-module/pages/[...post]/index.js
View file @
937884b6
import
styles
from
'./index.module.css'
import
styles1
from
'./index.module.css'
import
styles2
from
'./55css.module.css'
export
default
()
=>
(
export
default
()
=>
(
<
div
className
=
{
styles
.
home
}
id
=
"my-div"
>
<
div
className
=
{
styles
1
.
home
+
' '
+
styles2
.
home
}
id
=
"my-div"
>
hello
world
hello
world
<
/div
>
<
/div
>
)
)
test/integration/css-modules/test/index.test.js
View file @
937884b6
...
@@ -524,11 +524,13 @@ describe('Catch-all Route CSS Module Usage', () => {
...
@@ -524,11 +524,13 @@ describe('Catch-all Route CSS Module Usage', () => {
it
(
'should apply styles correctly'
,
async
()
=>
{
it
(
'should apply styles correctly'
,
async
()
=>
{
const
browser
=
await
webdriver
(
appPort
,
'/post-1'
)
const
browser
=
await
webdriver
(
appPort
,
'/post-1'
)
const
b
ackground
=
await
browser
const
b
g
=
await
browser
.
elementByCss
(
'#my-div'
)
.
elementByCss
(
'#my-div'
)
.
getComputedCss
(
'background-color'
)
.
getComputedCss
(
'background-color'
)
expect
(
bg
).
toMatch
(
/rgb
(
a|
)\(
255, 0, 0/
)
expect
(
background
).
toMatch
(
/rgb
(
a|
)\(
255, 0, 0/
)
const
fg
=
await
browser
.
elementByCss
(
'#my-div'
).
getComputedCss
(
'color'
)
expect
(
fg
).
toMatch
(
/rgb
(
a|
)\(
0, 128, 0/
)
})
})
it
(
`should've emitted a single CSS file`
,
async
()
=>
{
it
(
`should've emitted a single CSS file`
,
async
()
=>
{
...
@@ -541,7 +543,7 @@ describe('Catch-all Route CSS Module Usage', () => {
...
@@ -541,7 +543,7 @@ describe('Catch-all Route CSS Module Usage', () => {
const
cssContent
=
await
readFile
(
join
(
cssFolder
,
cssFiles
[
0
]),
'utf8'
)
const
cssContent
=
await
readFile
(
join
(
cssFolder
,
cssFiles
[
0
]),
'utf8'
)
expect
(
cssContent
.
replace
(
/
\/\*
.*
?\*\/
/g
,
''
).
trim
()).
toMatchInlineSnapshot
(
expect
(
cssContent
.
replace
(
/
\/\*
.*
?\*\/
/g
,
''
).
trim
()).
toMatchInlineSnapshot
(
`"._
post__home__38gR-{background:red
}"`
`"._
__post__home__38gR-{background:red}.__55css_home__qxXcH{color:green
}"`
)
)
})
})
})
})
test/integration/scss-modules/test/index.test.js
View file @
937884b6
...
@@ -540,7 +540,7 @@ describe('Catch-all Route CSS Module Usage', () => {
...
@@ -540,7 +540,7 @@ describe('Catch-all Route CSS Module Usage', () => {
const
cssContent
=
await
readFile
(
join
(
cssFolder
,
cssFiles
[
0
]),
'utf8'
)
const
cssContent
=
await
readFile
(
join
(
cssFolder
,
cssFiles
[
0
]),
'utf8'
)
expect
(
cssContent
.
replace
(
/
\/\*
.*
?\*\/
/g
,
''
).
trim
()).
toMatchInlineSnapshot
(
expect
(
cssContent
.
replace
(
/
\/\*
.*
?\*\/
/g
,
''
).
trim
()).
toMatchInlineSnapshot
(
`"._post__home__psZf9{background:red}"`
`"._
__
post__home__psZf9{background:red}"`
)
)
})
})
})
})
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