postcss-zindex
Advanced tools
Comparing version 4.0.1 to 5.0.0-rc.0
@@ -1,55 +0,31 @@ | ||
# 4.0.0-rc.0 | ||
# Change Log | ||
* Breaking: Drops support for Node 0.12, we now require at least Node 4. | ||
* Breaking: Update PostCSS to 6.0.0. | ||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
# 2.2.0 | ||
# 5.0.0-rc.0 (2021-02-19) | ||
* Added an option to set the starting index, useful to mitigate conflicts with | ||
third-party CSS files. | ||
* Performance improvements, including O(1) lookup of cached values rather than | ||
O(n), aborting PostCSS walk altogether when a negative index is found, and | ||
not running an optimize step if there are no z-index declarations. | ||
# 2.1.1 | ||
### chore | ||
* Fixes an issue where all positive indices before a negative index were | ||
transformed (thanks to @niccai). | ||
* minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11)) | ||
# 2.1.0 | ||
* Now aborts early when encountering negative indices, making the transform | ||
safer overall. | ||
### Features | ||
# 2.0.1 | ||
* migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49)) | ||
* Improved performance of the module by sorting/deduplicating values in one pass | ||
instead of per-value (thanks to @pgilad). | ||
# 2.0.0 | ||
### BREAKING CHANGES | ||
* Upgraded to PostCSS 5. | ||
* minimum supported `postcss` version is `8.2.1` | ||
* minimum require version of node is 10.13 | ||
# 1.1.3 | ||
* Improved performance by iterating the AST in a single pass and caching nodes for the second iteration. | ||
# 1.1.2 | ||
## 4.1.2 (2018-09-25) | ||
* Documentation/metadata tweaks for plugin guidelines compatibility. | ||
# 1.1.1 | ||
### Bug Fixes | ||
* Corrected dependency tree when installing from npm. | ||
# 1.1.0 | ||
* Now uses the PostCSS `4.1` plugin API. | ||
# 1.0.1 | ||
* Adds a JSHint config, code tidied up. | ||
# 1.0.0 | ||
* Initial release. | ||
* **postcss-merge-longhand:** not mangle border output ([#555](https://github.com/cssnano/cssnano/issues/555)) ([9a70605](https://github.com/cssnano/cssnano/commit/9a706050b621e7795a9bf74eb7110b5c81804ffe)), closes [#553](https://github.com/cssnano/cssnano/issues/553) [#554](https://github.com/cssnano/cssnano/issues/554) |
@@ -1,49 +0,59 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _postcss = require('postcss'); | ||
var _layerCache = _interopRequireDefault(require("./lib/layerCache")); | ||
var _layerCache = require('./lib/layerCache'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _layerCache2 = _interopRequireDefault(_layerCache); | ||
function pluginCreator(opts = {}) { | ||
return { | ||
postcssPlugin: 'postcss-zindex', | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
prepare() { | ||
const cache = new _layerCache.default(opts); | ||
return { | ||
OnceExit(css) { | ||
const nodes = []; | ||
let abort = false; // First pass; cache all z indexes | ||
exports.default = (0, _postcss.plugin)('postcss-zindex', (opts = {}) => { | ||
return css => { | ||
const cache = new _layerCache2.default(opts); | ||
const nodes = []; | ||
let abort = false; | ||
// First pass; cache all z indexes | ||
css.walkDecls(/z-index/i, decl => { | ||
css.walkDecls(/z-index/i, decl => { | ||
// Check that no negative values exist. Rebasing is only | ||
// safe if all indices are positive numbers. | ||
if (decl.value[0] === '-') { | ||
abort = true; | ||
// Stop PostCSS iterating through the rest of the decls | ||
return false; | ||
abort = true; // Stop PostCSS iterating through the rest of the decls | ||
return false; | ||
} | ||
nodes.push(decl); | ||
cache.addValue(decl.value); | ||
}); | ||
}); // Abort if we found any negative values | ||
// or there are no z-index declarations | ||
// Abort if we found any negative values | ||
// or there are no z-index declarations | ||
if (abort || !nodes.length) { | ||
if (abort || !nodes.length) { | ||
return; | ||
} | ||
} | ||
cache.optimizeValues(); | ||
cache.optimizeValues(); // Second pass; optimize | ||
// Second pass; optimize | ||
nodes.forEach(decl => { | ||
nodes.forEach(decl => { | ||
// Need to coerce to string so that the | ||
// AST is updated correctly | ||
decl.value = cache.getValue(decl.value).toString(); | ||
}); | ||
}; | ||
}); | ||
module.exports = exports['default']; | ||
}); | ||
} | ||
}; | ||
} | ||
}; | ||
} | ||
pluginCreator.postcss = true; | ||
var _default = pluginCreator; | ||
exports.default = _default; | ||
module.exports = exports.default; |
@@ -1,57 +0,57 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _has = require('has'); | ||
var _has = _interopRequireDefault(require("has")); | ||
var _has2 = _interopRequireDefault(_has); | ||
var _uniqs = _interopRequireDefault(require("uniqs")); | ||
var _uniqs = require('uniqs'); | ||
var _uniqs2 = _interopRequireDefault(_uniqs); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function LayerCache(opts) { | ||
this._values = []; | ||
this._startIndex = opts.startIndex || 1; | ||
this._values = []; | ||
this._startIndex = opts.startIndex || 1; | ||
} | ||
function ascending(a, b) { | ||
return a - b; | ||
return a - b; | ||
} | ||
function reduceValues(list, value, index) { | ||
list[value] = index + this._startIndex; | ||
return list; | ||
list[value] = index + this._startIndex; | ||
return list; | ||
} | ||
LayerCache.prototype._findValue = function (value) { | ||
if ((0, _has2.default)(this._values, value)) { | ||
return this._values[value]; | ||
} | ||
return false; | ||
if ((0, _has.default)(this._values, value)) { | ||
return this._values[value]; | ||
} | ||
return false; | ||
}; | ||
LayerCache.prototype.optimizeValues = function () { | ||
this._values = (0, _uniqs2.default)(this._values).sort(ascending).reduce(reduceValues.bind(this), {}); | ||
this._values = (0, _uniqs.default)(this._values).sort(ascending).reduce(reduceValues.bind(this), {}); | ||
}; | ||
LayerCache.prototype.addValue = function (value) { | ||
let parsedValue = parseInt(value, 10); | ||
// pass only valid values | ||
if (!parsedValue || parsedValue < 0) { | ||
return; | ||
} | ||
this._values.push(parsedValue); | ||
let parsedValue = parseInt(value, 10); // pass only valid values | ||
if (!parsedValue || parsedValue < 0) { | ||
return; | ||
} | ||
this._values.push(parsedValue); | ||
}; | ||
LayerCache.prototype.getValue = function (value) { | ||
let parsedValue = parseInt(value, 10); | ||
return this._findValue(parsedValue) || value; | ||
let parsedValue = parseInt(value, 10); | ||
return this._findValue(parsedValue) || value; | ||
}; | ||
exports.default = LayerCache; | ||
module.exports = exports['default']; | ||
var _default = LayerCache; | ||
exports.default = _default; | ||
module.exports = exports.default; |
{ | ||
"name": "postcss-zindex", | ||
"version": "4.0.1", | ||
"version": "5.0.0-rc.0", | ||
"description": "Reduce z-index values with PostCSS.", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/" | ||
"prebuild": "del-cli dist", | ||
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"", | ||
"prepublish": "yarn build" | ||
}, | ||
@@ -24,10 +26,5 @@ "files": [ | ||
"dependencies": { | ||
"has": "^1.0.0", | ||
"postcss": "^7.0.0", | ||
"has": "^1.0.3", | ||
"uniqs": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.0.0", | ||
"cross-env": "^5.0.0" | ||
}, | ||
"homepage": "https://github.com/cssnano/cssnano", | ||
@@ -44,4 +41,11 @@ "author": { | ||
"engines": { | ||
"node": ">=6.9.0" | ||
} | ||
"node": "^10 || ^12 || >=14.0" | ||
}, | ||
"devDependencies": { | ||
"postcss": "^8.2.1" | ||
}, | ||
"peerDependencies": { | ||
"postcss": "^8.2.1" | ||
}, | ||
"gitHead": "8c16e67a4d24a13ac7e09a36d4faf504196efd0f" | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
8241
1
85
1
1
+ Addednanoid@3.3.7(transitive)
+ Addedpicocolors@1.0.1(transitive)
+ Addedpostcss@8.4.38(transitive)
+ Addedsource-map-js@1.2.0(transitive)
- Removedpostcss@^7.0.0
- Removedpicocolors@0.2.1(transitive)
- Removedpostcss@7.0.39(transitive)
- Removedsource-map@0.6.1(transitive)
Updatedhas@^1.0.3