🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

postcss-reduce-initial

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-reduce-initial - npm Package Compare versions

Comparing version

to
4.0.0-rc.0

data/fromInitial.json

11

CHANGELOG.md

@@ -0,1 +1,12 @@

# 4.0.0-rc.0
* Breaking: Drops support for Node 0.12, we now require at least Node 4.
* Breaking: Update PostCSS to 6.0.0.
* Added: This module can now convert initial values *to* the `initial` keyword,
but only when the browser support is sufficient. You may use Browserslist to
supply a list of browsers; we recommend using the config file as the same
values will be propagated to other cssnano plugins which have the same
functionality. See https://github.com/ai/browserslist#config-file for
more details.
# 1.0.1

@@ -2,0 +13,0 @@

43

dist/index.js
'use strict';
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _postcss = require('postcss');
var _values = require('../data/values.json');
var _has = require('has');
var _values2 = _interopRequireDefault(_values);
var _has2 = _interopRequireDefault(_has);
var _browserslist = require('browserslist');
var _browserslist2 = _interopRequireDefault(_browserslist);
var _caniuseApi = require('caniuse-api');
var _fromInitial = require('../data/fromInitial.json');
var _fromInitial2 = _interopRequireDefault(_fromInitial);
var _toInitial = require('../data/toInitial.json');
var _toInitial2 = _interopRequireDefault(_toInitial);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var initial = 'initial';
exports.default = (0, _postcss.plugin)('postcss-reduce-initial', function () {
return function (css) {
return function (css, result) {
var resultOpts = result.opts || {};
var browsers = (0, _browserslist2.default)(null, {
stats: resultOpts.stats,
path: __dirname,
env: resultOpts.env
});
var initialSupport = (0, _caniuseApi.isSupported)('css-initial-value', browsers);
css.walkDecls(function (decl) {
if (decl.value !== 'initial') {
var prop = decl.prop;
if (initialSupport && (0, _has2.default)(_toInitial2.default, prop) && decl.value === _toInitial2.default[prop]) {
decl.value = initial;
return;
}
if (_values2.default[decl.prop]) {
decl.value = _values2.default[decl.prop];
if (decl.value !== initial || !_fromInitial2.default[prop]) {
return;
}
decl.value = _fromInitial2.default[prop];
});

@@ -23,0 +52,0 @@ };

51

package.json
{
"name": "postcss-reduce-initial",
"version": "1.0.1",
"version": "4.0.0-rc.0",
"description": "Reduce initial definitions to the actual initial value, where possible.",

@@ -12,9 +12,4 @@ "main": "dist/index.js",

"scripts": {
"acquire": "node ./dist/acquire.js > ./data/values.json",
"contributorAdd": "all-contributors add",
"contributorGenerate": "all-contributors generate",
"pretest": "eslint src",
"prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
"test": "ava",
"test-012": "ava"
"acquire": "babel-node ./src/acquire.js",
"prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/,src/acquire.js"
},

@@ -28,21 +23,10 @@ "keywords": [

"devDependencies": {
"all-contributors-cli": "^3.0.5",
"ava": "^0.17.0",
"babel-cli": "^6.3.17",
"babel-core": "^6.3.26",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.3.13",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-stage-0": "^6.3.13",
"babel-register": "^6.9.0",
"del-cli": "^0.2.0",
"eslint": "^3.0.0",
"eslint-config-cssnano": "^3.0.0",
"eslint-plugin-babel": "^3.3.0",
"eslint-plugin-import": "^2.0.1",
"got": "^6.3.0",
"html2plaintext": "^1.0.1",
"is-html": "^1.0.0"
"babel-cli": "^6.0.0",
"cross-env": "^3.0.0",
"got": "^6.0.0",
"html2plaintext": "^1.0.0",
"is-html": "^1.0.0",
"write-file": "^1.0.0"
},
"homepage": "https://github.com/ben-eb/postcss-reduce-initial",
"homepage": "https://github.com/ben-eb/cssnano",
"author": {

@@ -53,12 +37,15 @@ "name": "Ben Briggs",

},
"repository": "ben-eb/postcss-reduce-initial",
"repository": "ben-eb/cssnano",
"dependencies": {
"postcss": "^5.0.4"
"browserslist": "^2.0.0",
"caniuse-api": "^2.0.0",
"has": "^1.0.0",
"postcss": "^6.0.0"
},
"ava": {
"require": "babel-register"
"bugs": {
"url": "https://github.com/ben-eb/cssnano/issues"
},
"eslintConfig": {
"extends": "cssnano"
"engines": {
"node": ">=4"
}
}

@@ -1,2 +0,2 @@

# [postcss][postcss]-reduce-initial [![Build Status](https://travis-ci.org/ben-eb/postcss-reduce-initial.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-reduce-initial.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-reduce-initial.svg)][deps]
# [postcss][postcss]-reduce-initial

@@ -15,11 +15,14 @@ > Reduce `initial` definitions to the *actual* initial value, where possible.

## Example
## Examples
This module will replace the `initial` CSS keyword with the *actual* value,
when this value is smaller than the `initial` definition itself. For example,
the initial value for the `min-width` property is `0`; therefore, these two
definitions are equivalent;
See the [data](data) for more conversions. This data is courtesy
of Mozilla.
### Input
### Convert `initial` values
When the `initial` keyword is longer than the property value, it will
be converted:
#### Input
```css

@@ -31,3 +34,3 @@ h1 {

### Output
#### Output

@@ -40,6 +43,28 @@ ```css

See the [data](data/values.json) for more conversions. This data is courtesy
of Mozilla.
### Convert values back to `initial`
When the `initial` value is smaller than the property value, it will
be converted:
#### Input
```css
h1 {
transform-box: border-box;
}
```
#### Output
```css
h1 {
transform-box: initial;
}
```
This conversion is only applied when you supply a browsers list that all support
the `initial` keyword; it's worth noting that Internet Explorer has no support.
## Usage

@@ -53,13 +78,5 @@

Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
See [CONTRIBUTORS.md](https://github.com/ben-eb/cssnano/blob/master/CONTRIBUTORS.md).
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars.githubusercontent.com/u/1282980?v=3" width="100px;"/><br /><sub>Ben Briggs</sub>](http://beneb.info)<br />[💻](https://github.com/ben-eb/postcss-reduce-initial/commits?author=ben-eb) [📖](https://github.com/ben-eb/postcss-reduce-initial/commits?author=ben-eb) 👀 [⚠️](https://github.com/ben-eb/postcss-reduce-initial/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/551712?v=3" width="100px;"/><br /><sub>Chris Walker</sub>](http://thechriswalker.github.com/)<br />[🐛](https://github.com/ben-eb/postcss-reduce-initial/issues?q=author%3Athechriswalker) [💻](https://github.com/ben-eb/postcss-reduce-initial/commits?author=thechriswalker) |
| :---: | :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors] specification. Contributions of
any kind welcome!
## License

@@ -74,7 +91,2 @@

[all-contributors]: https://github.com/kentcdodds/all-contributors
[ci]: https://travis-ci.org/ben-eb/postcss-reduce-initial
[deps]: https://gemnasium.com/ben-eb/postcss-reduce-initial
[npm]: http://badge.fury.io/js/postcss-reduce-initial
[postcss]: https://github.com/postcss/postcss