postcss-calc
Advanced tools
Comparing version
@@ -0,1 +1,5 @@ | ||
# 5.1.0 - 2016-01-07 | ||
- Added: "warnWhenCannotResolve" option to warn when calc() are not reduced to a single value | ||
# 5.0.0 - 2015-08-25 | ||
@@ -2,0 +6,0 @@ |
11
index.js
@@ -8,2 +8,4 @@ /** | ||
var CONTAINS_CALC = /calc\(.*\)/ | ||
/** | ||
@@ -16,4 +18,6 @@ * PostCSS plugin to reduce calc() function calls. | ||
var preserve = options.preserve | ||
var warnWhenCannotResolve = options.warnWhenCannotResolve | ||
return function(style) { | ||
return function(style, result) { | ||
style.walkDecls(function transformDecl(decl) { | ||
@@ -27,2 +31,7 @@ if (!decl.value || decl.value.indexOf("calc(") === -1) { | ||
if (warnWhenCannotResolve && CONTAINS_CALC.test(value)) { | ||
result.warn("Could not reduce expression: " + decl.value, | ||
{plugin: "postcss-calc", node: decl}) | ||
} | ||
if (!preserve) { | ||
@@ -29,0 +38,0 @@ decl.value = value |
{ | ||
"name": "postcss-calc", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "PostCSS plugin to reduce calc()", | ||
@@ -14,6 +14,3 @@ "keywords": [ | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/postcss/postcss-calc.git" | ||
}, | ||
"repository": "https://github.com/postcss/postcss-calc.git", | ||
"files": [ | ||
@@ -20,0 +17,0 @@ "index.js" |
@@ -110,2 +110,13 @@ # postcss-calc [](https://travis-ci.org/postcss/postcss-calc) | ||
#### `warnWhenCannotResolve` (default: `false`) | ||
Adds warnings when calc() are not reduced to a single value. | ||
```js | ||
var out = postcss() | ||
.use(calc({warnWhenCannotResolve: true})) | ||
.process(css) | ||
.css | ||
``` | ||
--- | ||
@@ -112,0 +123,0 @@ |
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
7252
8.82%39
18.18%137
8.73%1
Infinity%