postcss-color-function
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -0,1 +1,6 @@ | ||
# 2.0.1 - 2016-03-15 | ||
- Fixed: whitespace are retained between color() usage. | ||
([#27](https://github.com/postcss/postcss-color-function/pull/27)) | ||
# 2.0.0 - 2015-09-07 | ||
@@ -2,0 +7,0 @@ |
29
index.js
@@ -5,3 +5,3 @@ /** | ||
var postcss = require("postcss") | ||
var balanced = require("balanced-match") | ||
var parser = require("postcss-value-parser") | ||
var colorFn = require("css-color-function") | ||
@@ -21,3 +21,3 @@ var helpers = require("postcss-message-helpers") | ||
decl.value = helpers.try(function transformColorValue() { | ||
return transformColor(decl.value, decl.source) | ||
return transformColor(decl.value) | ||
}, decl.source) | ||
@@ -34,20 +34,11 @@ }) | ||
*/ | ||
function transformColor(string, source) { | ||
var index = string.search(/(^|[^\w\-])color\(/) | ||
function transformColor(string) { | ||
return parser(string).walk(function(node) { | ||
if (node.type !== "function" || node.value !== "color") { | ||
return | ||
} | ||
if (index === -1) { | ||
return string | ||
} | ||
// NOTE: regexp search beginning of line of non char symbol before `color(`. | ||
// Offset used for second case. | ||
index = index === 0 ? index : index + 1 | ||
var fn = string.slice(index) | ||
var balancedMatches = balanced("(", ")", fn) | ||
if (!balancedMatches) { | ||
throw new Error("Missing closing parentheses in '" + string + "'", source) | ||
} | ||
return string.slice(0, index) + colorFn.convert("color(" + balancedMatches.body + ")") + transformColor(balancedMatches.post) | ||
node.value = colorFn.convert(parser.stringify(node)) | ||
node.type = "word" | ||
}).toString() | ||
} |
{ | ||
"name": "postcss-color-function", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "PostCSS plugin to transform W3C CSS color function to more compatible CSS.", | ||
@@ -15,6 +15,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/postcss/postcss-color-function.git" | ||
}, | ||
"repository": "https://github.com/postcss/postcss-color-function.git", | ||
"files": [ | ||
@@ -24,6 +21,6 @@ "index.js" | ||
"dependencies": { | ||
"balanced-match": "^0.1.0", | ||
"css-color-function": "^1.2.0", | ||
"postcss": "^5.0.4", | ||
"postcss-message-helpers": "^2.0.0" | ||
"postcss-message-helpers": "^2.0.0", | ||
"postcss-value-parser": "^3.3.0" | ||
}, | ||
@@ -33,2 +30,3 @@ "devDependencies": { | ||
"jshint": "^2.5.6", | ||
"npmpub": "^3.1.0", | ||
"tape": "^3.0.0" | ||
@@ -38,4 +36,5 @@ }, | ||
"lint": "jscs *.js **/*.js && jshint . --exclude-path .gitignore", | ||
"test": "npm run lint && tape test" | ||
"test": "npm run lint && tape test", | ||
"release": "npmpub" | ||
} | ||
} |
@@ -109,2 +109,2 @@ # postcss-color-function [](https://travis-ci.org/postcss/postcss-color-function) | ||
[specs]: (http://dev.w3.org/csswg/css-color/#modifying-colors) | ||
[specs]: http://dev.w3.org/csswg/css-color/#modifying-colors |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
6776
4
37
1
+ Addedpostcss-value-parser@^3.3.0
+ Addedpostcss-value-parser@3.3.1(transitive)
- Removedbalanced-match@^0.1.0