postcss-property-lookup
Advanced tools
Comparing version 0.1.0 to 0.2.0
16
index.js
@@ -6,10 +6,16 @@ var postcss = require('postcss'); | ||
function propertyLookup() { | ||
return function(css) { | ||
return function(css, result) { | ||
css.eachRule(function(rule) { | ||
rule.replaceValues(/@([a-z-]+)/g, { fast: '@' }, function(orig, prop) { | ||
var replacement; | ||
rule.replaceValues(/@([a-z-]+)(\s?)/g, { fast: '@' }, function(orig, prop, space) { | ||
var replacementVal; | ||
rule.eachDecl(prop, function(decl) { | ||
replacement = decl.value; | ||
replacementVal = decl.value; | ||
}); | ||
return replacement === undefined ? orig : replacement; | ||
if (replacementVal) { | ||
return replacementVal + space; | ||
} else { | ||
result.warn('Unable to find property ' + orig, { node: rule }); | ||
return ''; | ||
} | ||
}); | ||
@@ -16,0 +22,0 @@ }); |
{ | ||
"name": "postcss-property-lookup", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "PostCSS plugin that allows referencing property values without a variable", | ||
"keywords": ["postcss", "css", "postcss-plugin", "property-lookup"], | ||
"keywords": [ | ||
"postcss", | ||
"css", | ||
"postcss-plugin", | ||
"property-lookup" | ||
], | ||
"author": "Simon Smith <me@simonsmith.io>", | ||
@@ -10,3 +15,3 @@ "license": "MIT", | ||
"type": "git", | ||
"url": "https://github.com/simonsmith/postcss-property-lookup.git" | ||
"url": "https://github.com/simonsmith/postcss-property-lookup.git" | ||
}, | ||
@@ -18,5 +23,5 @@ "dependencies": { | ||
"gulp-eslint": "^0.12.0", | ||
"gulp-mocha": "^2.0.1", | ||
"chai": "^2.3.0", | ||
"gulp": "^3.8.11" | ||
"gulp-mocha": "^2.0.1", | ||
"chai": "^2.3.0", | ||
"gulp": "^3.8.11" | ||
}, | ||
@@ -23,0 +28,0 @@ "scripts": { |
3931
20