diff --git a/objectifier.js b/objectifier.js index 0881471..bd47fd2 100644 --- a/objectifier.js +++ b/objectifier.js @@ -1,5 +1,3 @@ -let camelcase = require('camelcase-css') - let UNITLESS = { boxFlex: true, boxFlexGroup: true, @@ -33,6 +31,34 @@ function atRule(node) { } } +// From https://github.com/hyperz111/fast-camelcase-css +function camelcase(property) { + property = property.toLowerCase() + + if (property === 'float') return 'cssFloat' + + let index = property.indexOf('-') + // Early return if don't have a dash + if (index === -1) return property + + // Microsoft vendor-prefixes are uniquely cased + if (property.startsWith('-ms-')) { + property = property.substring(1) + index = property.indexOf('-') + } + + let cursor = 0 + let result = '' + + do { + result += property.substring(cursor, index) + property[index + 1].toUpperCase() + cursor = index + 2 + index = property.indexOf('-', cursor) + } while (index !== -1) + + return result + property.substring(cursor) +} + function process(node, options = {}) { let name let result = {} diff --git a/package.json b/package.json index 1f151cf..bc8ba9b 100644 --- a/package.json +++ b/package.json @@ -48,9 +48,6 @@ "peerDependencies": { "postcss": "^8.4.21" }, - "dependencies": { - "camelcase-css": "^2.0.1" - }, "devDependencies": { "@logux/eslint-config": "^57.0.0", "actions-up": "^1.7.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 60fde5e..82266f0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,10 +7,6 @@ settings: importers: .: - dependencies: - camelcase-css: - specifier: ^2.0.1 - version: 2.0.1 devDependencies: '@logux/eslint-config': specifier: ^57.0.0 @@ -289,49 +285,41 @@ packages: resolution: {integrity: sha512-34gw7PjDGB9JgePJEmhEqBhWvCiiWCuXsL9hYphDF7crW7UgI05gyBAi6MF58uGcMOiOqSJ2ybEeCvHcq0BCmQ==} cpu: [arm64] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-arm64-musl@1.11.1': resolution: {integrity: sha512-RyMIx6Uf53hhOtJDIamSbTskA99sPHS96wxVE/bJtePJJtpdKGXO1wY90oRdXuYOGOTuqjT8ACccMc4K6QmT3w==} cpu: [arm64] os: [linux] - libc: [musl] '@unrs/resolver-binding-linux-ppc64-gnu@1.11.1': resolution: {integrity: sha512-D8Vae74A4/a+mZH0FbOkFJL9DSK2R6TFPC9M+jCWYia/q2einCubX10pecpDiTmkJVUH+y8K3BZClycD8nCShA==} cpu: [ppc64] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-riscv64-gnu@1.11.1': resolution: {integrity: sha512-frxL4OrzOWVVsOc96+V3aqTIQl1O2TjgExV4EKgRY09AJ9leZpEg8Ak9phadbuX0BA4k8U5qtvMSQQGGmaJqcQ==} cpu: [riscv64] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-riscv64-musl@1.11.1': resolution: {integrity: sha512-mJ5vuDaIZ+l/acv01sHoXfpnyrNKOk/3aDoEdLO/Xtn9HuZlDD6jKxHlkN8ZhWyLJsRBxfv9GYM2utQ1SChKew==} cpu: [riscv64] os: [linux] - libc: [musl] '@unrs/resolver-binding-linux-s390x-gnu@1.11.1': resolution: {integrity: sha512-kELo8ebBVtb9sA7rMe1Cph4QHreByhaZ2QEADd9NzIQsYNQpt9UkM9iqr2lhGr5afh885d/cB5QeTXSbZHTYPg==} cpu: [s390x] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-x64-gnu@1.11.1': resolution: {integrity: sha512-C3ZAHugKgovV5YvAMsxhq0gtXuwESUKc5MhEtjBpLoHPLYM+iuwSj3lflFwK3DPm68660rZ7G8BMcwSro7hD5w==} cpu: [x64] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-x64-musl@1.11.1': resolution: {integrity: sha512-rV0YSoyhK2nZ4vEswT/QwqzqQXw5I6CjoaYMOX0TqBlWhojUf8P94mvI7nuJTeaCkkds3QE4+zS8Ko+GdXuZtA==} cpu: [x64] os: [linux] - libc: [musl] '@unrs/resolver-binding-wasm32-wasi@1.11.1': resolution: {integrity: sha512-5u4RkfxJm+Ng7IWgkzi3qrFOvLvQYnPBmjmZQ8+szTK/b31fQCnleNl1GgEt7nIsZRIf5PLhPwT0WM+q45x/UQ==} @@ -465,10 +453,6 @@ packages: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} - camelcase-css@2.0.1: - resolution: {integrity: sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==} - engines: {node: '>= 6'} - chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} @@ -1942,8 +1926,6 @@ snapshots: callsites@3.1.0: {} - camelcase-css@2.0.1: {} - chalk@4.1.2: dependencies: ansi-styles: 4.3.0