camelcase-css
Advanced tools
Comparing version 1.0.1 to 2.0.0
40
index.js
"use strict"; | ||
var pattern = /-(\w|$)/g; | ||
const pattern = /-(\w|$)/g; | ||
const callback = (dashChar, char) => char.toUpperCase(); | ||
function callback(dashChar, char) | ||
const camelCaseCSS = property => | ||
{ | ||
return char.toUpperCase(); | ||
} | ||
property = property.toLowerCase(); | ||
function camelCaseCSS(property) | ||
{ | ||
// NOTE :: IE8's "styleFloat" is intentionally not supported | ||
if (property === "float") return "cssFloat"; | ||
/* | ||
Microsoft vendor-prefixed properties are camel cased | ||
differently than other browsers: | ||
-webkit-something => WebkitSomething | ||
-moz-something => MozSomething | ||
-ms-something => msSomething | ||
*/ | ||
if (property.indexOf("-ms-") === 0) | ||
if (property === "float") | ||
{ | ||
property = property.substr(1); | ||
return "cssFloat"; | ||
} | ||
return property.replace(pattern, callback); | ||
} | ||
// Microsoft vendor-prefixes are uniquely cased | ||
else if (property.indexOf("-ms-") === 0) | ||
{ | ||
return property.substr(1).replace(pattern, callback); | ||
} | ||
else | ||
{ | ||
return property.replace(pattern, callback); | ||
} | ||
}; | ||
@@ -34,0 +28,0 @@ |
{ | ||
"name": "camelcase-css", | ||
"description": "Convert a dash-separated CSS property to a camelCased DOM property.", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
"homepage": "https://github.com/stevenvachon/camelcase-css", | ||
"author": { | ||
"name": "Steven Vachon", | ||
"email": "contact@svachon.com", | ||
"url": "http://www.svachon.com/" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/stevenvachon/camelcase-css.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/stevenvachon/camelcase-css/issues" | ||
}, | ||
"author": "Steven Vachon <contact@svachon.com> (https://www.svachon.com/)", | ||
"repository": "stevenvachon/camelcase-css", | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"mocha": "^2.4.5" | ||
"chai": "^4.1.2", | ||
"mocha": "^5.0.5" | ||
}, | ||
"engines": { | ||
"node": ">= 0.10" | ||
"node": ">= 6" | ||
}, | ||
"scripts": { | ||
"test": "mocha test.js --reporter spec --check-leaks --bail --no-exit" | ||
"test": "mocha test.js --check-leaks --bail" | ||
}, | ||
@@ -29,0 +18,0 @@ "files": [ |
@@ -1,2 +0,2 @@ | ||
# camelcase-css [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][david-image]][david-url] | ||
# camelcase-css [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] | ||
@@ -7,3 +7,3 @@ > Convert a dash-separated CSS property to a camelCased DOM property. | ||
## Installation | ||
[Node.js](http://nodejs.org/) `>= 0.10` is required. Type this at the command line: | ||
[Node.js](http://nodejs.org/) `>= 6` is required. Type this at the command line: | ||
```shell | ||
@@ -16,3 +16,3 @@ npm install camelcase-css | ||
```js | ||
var camelCaseCSS = require("camelcase-css"); | ||
const camelCaseCSS = require("camelcase-css"); | ||
@@ -30,3 +30,1 @@ camelCaseCSS("-webkit-border-radius"); //-> WebkitBorderRadius | ||
[travis-url]: https://travis-ci.org/stevenvachon/camelcase-css | ||
[david-image]: https://img.shields.io/david/stevenvachon/camelcase-css.svg | ||
[david-url]: https://david-dm.org/stevenvachon/camelcase-css |
3104
22
28