Skip to content

Commit 39fa098

Browse files
committed
fix escaping non-string values
1 parent 5b6b470 commit 39fa098

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

example/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ body {
1313

1414
.delorean {
1515
z-index: -1955;
16+
width: 5px;
1617
}
1718

1819
#chucknorris {

lib/cssToJss.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ function toJssRules(cssRules, options) {
5353
const fallbacks = style.fallbacks || (style.fallbacks = [])
5454
fallbacks.splice(0, 0, { [property]: style[property] })
5555
}
56-
style[property] = stripUnit(decl.value).replace(/\\/g, '\\\\')
56+
style[property] = stripUnit(decl.value)
57+
if (typeof style[property] === 'string') {
58+
style[property] = style[property].replace(/\\/g, '\\\\')
59+
}
5760
})
5861
}
5962

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"jss": "bin/jss.js"
77
},
88
"scripts": {
9-
"cssToJss": "node bin/cli example/style.css",
9+
"cssToJss": "node bin/jss convert example/style.css -f js -e cjs",
1010
"example": "babel-node example/test.js"
1111
},
1212
"repository": {

0 commit comments

Comments
 (0)