Skip to content

Commit e8fdc0d

Browse files
authored
Merge pull request #85 from hyperz111/fast-camelcase-css
chore: use fast camelcase function
2 parents d2e2769 + d6d7f32 commit e8fdc0d

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
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 = {}

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@
4848
"peerDependencies": {
4949
"postcss": "^8.4.21"
5050
},
51-
"dependencies": {
52-
"camelcase-css": "^2.0.1"
53-
},
5451
"devDependencies": {
5552
"@logux/eslint-config": "^57.0.0",
5653
"actions-up": "^1.7.0",

pnpm-lock.yaml

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)