Skip to content

Commit 8b5db72

Browse files
committed
use fast camelcase function
1 parent d2e2769 commit 8b5db72

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

objectifier.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
let camelcase = require('camelcase-css')
2-
31
let UNITLESS = {
42
boxFlex: true,
53
boxFlexGroup: true,
@@ -33,6 +31,34 @@ function atRule(node) {
3331
}
3432
}
3533

34+
// From https://github.com/hyperz111/fast-camelcase-css
35+
function camelcase(property) {
36+
property = property.toLowerCase()
37+
38+
if (property === 'float') return 'cssFloat'
39+
40+
let index = property.indexOf('-')
41+
// Early return if don't have a dash
42+
if (index === -1) return property
43+
44+
// Microsoft vendor-prefixes are uniquely cased
45+
if (property.startsWith('-ms-')) {
46+
property = property.substring(1)
47+
index = property.indexOf('-')
48+
}
49+
50+
let cursor = 0
51+
let result = ''
52+
53+
do {
54+
result += property.substring(cursor, index) + property[index + 1].toUpperCase()
55+
cursor = index + 2
56+
index = property.indexOf('-', cursor)
57+
} while (index !== -1)
58+
59+
return result + property.substring(cursor)
60+
}
61+
3662
function process(node, options = {}) {
3763
let name
3864
let result = {}

0 commit comments

Comments
 (0)