postcss-custom-properties
Advanced tools
Comparing version 0.4.0 to 1.0.0
@@ -0,19 +1,24 @@ | ||
# 1.0.0 - 2014-11-02 | ||
- Add warning when a custom prop is used in another place that :root | ||
- handle !important | ||
# 0.4.0 - 2014-09-30 | ||
* JS-defined properties override CSS-defined | ||
- JS-defined properties override CSS-defined | ||
# 0.3.1 - 2014-08-27 | ||
* nested custom properties usages are now correctly resolved | ||
* undefined var doesn't throw error anymore (just a console warning) & are kept as is in the output | ||
- Nested custom properties usages are now correctly resolved | ||
- Undefined var doesn't throw error anymore (just a console warning) & are kept as is in the output | ||
# 0.3.0 - 2014-08-26 | ||
* fallback now are always added by default ([see why](http://www.w3.org/TR/css-variables/#invalid-variables)) | ||
* `map` option renamed to `variables` | ||
- Fallback now are always added by default ([see why](http://www.w3.org/TR/css-variables/#invalid-variables)) | ||
- `map` option renamed to `variables` | ||
# 0.2.0 - 2014-08-22 | ||
* Add `map` option | ||
* GNU style error message | ||
- Add `map` option | ||
- GNU style error message | ||
@@ -20,0 +25,0 @@ # 0.1.0 - 2014-08-01 |
13
index.js
@@ -25,2 +25,3 @@ /** | ||
var map = {} | ||
var importantMap = {} | ||
@@ -36,2 +37,3 @@ // define variables | ||
if (rule.selectors.length !== 1 || rule.selectors[0] !== ":root" || rule.parent.type !== "root") { | ||
console.warn(gnuMessage("Non :root only custom properties in non root level are not supported (" + rule.selectors + ")")) | ||
return | ||
@@ -42,6 +44,7 @@ } | ||
var prop = decl.prop | ||
var value = decl.value | ||
if (prop && prop.indexOf(VAR_PROP_IDENTIFIER) === 0) { | ||
map[prop] = value | ||
if (!map[prop] || !importantMap[prop] || decl.important) { | ||
map[prop] = decl.value | ||
importantMap[prop] = decl.important | ||
} | ||
toRemove.push(i) | ||
@@ -127,3 +130,3 @@ } | ||
if (!replacement && !fallback) { | ||
console.warn(gnuMessage("variable '" + name + "' is undefined & don't have any fallback", source)) | ||
console.warn(gnuMessage("variable '" + name + "' is undefined and used without a fallback", source)) | ||
} | ||
@@ -172,3 +175,3 @@ | ||
function gnuMessage(message, source) { | ||
return (source ? (source.file ? source.file : "<css input>") + ":" + source.start.line + ":" + source.start.column : "") + " " + message | ||
return (source ? (source.file ? source.file : "<css input>") + ":" + source.start.line + ":" + source.start.column + " " : "") + message | ||
} |
{ | ||
"name": "postcss-custom-properties", | ||
"version": "0.4.0", | ||
"version": "1.0.0", | ||
"description": "PostCSS plugin to polyfill W3C CSS Custom Properties for cascading variables", | ||
@@ -13,3 +13,3 @@ "keywords": [ | ||
], | ||
"author": "MoOx", | ||
"author": "Maxime Thirouin", | ||
"license": "MIT", | ||
@@ -30,14 +30,11 @@ "repository": { | ||
"devDependencies": { | ||
"jscs": "^1.5.9", | ||
"jshint": "^2.5.2", | ||
"jshint-stylish": "^0.4.0", | ||
"postcss": "^2.1.0", | ||
"tap-colorize": "^1.2.0", | ||
"tape": "^2.13.4" | ||
"jscs": "^1.6.2", | ||
"jshint": "^2.5.6", | ||
"postcss": "^2.2.5", | ||
"tape": "^3.0.0" | ||
}, | ||
"scripts": { | ||
"jscs": "jscs *.js **/*.js", | ||
"jshint": "jshint . --exclude node_modules --reporter node_modules/jshint-stylish/stylish.js", | ||
"test": "npm run jscs && npm run jshint && tape test | tap-colorize" | ||
"lint": "jscs *.js **/*.js && jshint . --exclude-path .gitignore", | ||
"test": "npm run lint && tape test" | ||
} | ||
} |
@@ -5,6 +5,4 @@ # postcss-custom-properties [![Build Status](https://travis-ci.org/postcss/postcss-custom-properties.png)](https://travis-ci.org/postcss/postcss-custom-properties) | ||
**N.B.** For now the transformation _is not complete_. It currently just aims to provide a future-proof way of using a _limited subset (to `:root` selector)_ of the features provided by native CSS custom properties. | ||
**N.B.** The transformation _is not complete_. It currently just aims to provide a future-proof way of using a **limited subset (to `:root` selector)** of the features provided by native CSS custom properties. Read [#1](https://github.com/postcss/postcss-custom-properties/issues/1) & [#9](https://github.com/postcss/postcss-custom-properties/issues/9) to know why this limitation exists. | ||
_[Checkout opened issue to know the state of this plugin](https://github.com/postcss/postcss-custom-properties/issues)._ | ||
Works great with [postcss-calc](https://github.com/postcss/postcss-calc). | ||
@@ -11,0 +9,0 @@ |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
9849
4
145
1
84