postcss-color-hex-alpha
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -0,3 +1,7 @@ | ||
# 1.1.0 - 2014-11-25 | ||
- Enhanced exceptions | ||
# 1.0.0 - 2014-10-04 | ||
Initial release from [postcss-color](https://github.com/postcss/postcss-color) |
40
index.js
@@ -5,2 +5,3 @@ /** | ||
var color = require("color") | ||
var helpers = require("postcss-message-helpers") | ||
@@ -18,8 +19,10 @@ /** | ||
return function(style) { | ||
style.eachDecl(function transformDecl(dec) { | ||
if (!dec.value) { | ||
style.eachDecl(function transformDecl(decl) { | ||
if (!decl.value || decl.value.indexOf("#") === -1) { | ||
return | ||
} | ||
dec.value = transform(dec.value, dec.source) | ||
decl.value = helpers.try(function transformHexAlphaValue() { | ||
return transformHexAlpha(decl.value, decl.source) | ||
}, decl.source) | ||
}) | ||
@@ -30,23 +33,2 @@ } | ||
/** | ||
* Transform colors to rgb() or rgba() on a declaration value | ||
* | ||
* @param {String} string | ||
* @return {String} | ||
*/ | ||
function transform(string, source) { | ||
// order of transformation is important | ||
try { | ||
if (string.indexOf("#") > -1) { | ||
string = transformHexAlpha(string, source) | ||
} | ||
} | ||
catch (e) { | ||
throw new Error(gnuMessage(e.message, source)) | ||
} | ||
return string | ||
} | ||
/** | ||
* transform RGBA hexadecimal notations (#RRGGBBAA or #RGBA) to rgba(). | ||
@@ -95,11 +77,1 @@ * | ||
} | ||
/** | ||
* return GNU style message | ||
* | ||
* @param {String} message | ||
* @param {Object} source | ||
*/ | ||
function gnuMessage(message, source) { | ||
return (source ? (source.file ? source.file : "<css input>") + ":" + source.start.line + ":" + source.start.column : "") + " " + message | ||
} |
{ | ||
"name": "postcss-color-hex-alpha", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "PostCSS plugin to transform W3C RGBA hexadecimal notations (#RRGGBBAA or #RGBA) to more compatible CSS (rgba())", | ||
@@ -23,7 +23,7 @@ "keywords": [ | ||
"LICENSE", | ||
"README.md", | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"color": "^0.7.1" | ||
"color": "^0.7.1", | ||
"postcss-message-helpers": "^1.1.0" | ||
}, | ||
@@ -33,3 +33,3 @@ "devDependencies": { | ||
"jshint": "^2.5.6", | ||
"postcss": "^2.2.5", | ||
"postcss": "^3.0.0", | ||
"tape": "^3.0.0" | ||
@@ -36,0 +36,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5175
2
65
+ Addedpostcss-message-helpers@1.1.1(transitive)