postcss-zindex
Advanced tools
Comparing version 4.0.0-nightly.2020.1.9 to 4.0.0-nightly.2020.1.11
@@ -8,4 +8,2 @@ "use strict"; | ||
var _postcss = require("postcss"); | ||
var _layerCache = _interopRequireDefault(require("./lib/layerCache")); | ||
@@ -15,37 +13,49 @@ | ||
var _default = (0, _postcss.plugin)('postcss-zindex', (opts = {}) => { | ||
return css => { | ||
const cache = new _layerCache.default(opts); | ||
const nodes = []; | ||
let abort = false; // First pass; cache all z indexes | ||
function pluginCreator(opts = {}) { | ||
return { | ||
postcssPlugin: 'postcss-zindex', | ||
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 | ||
prepare() { | ||
const cache = new _layerCache.default(opts); | ||
return { | ||
OnceExit(css) { | ||
const nodes = []; | ||
let abort = false; // First pass; cache all z indexes | ||
return false; | ||
} | ||
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 | ||
nodes.push(decl); | ||
cache.addValue(decl.value); | ||
}); // Abort if we found any negative values | ||
// or there are no z-index declarations | ||
return false; | ||
} | ||
if (abort || !nodes.length) { | ||
return; | ||
nodes.push(decl); | ||
cache.addValue(decl.value); | ||
}); // Abort if we found any negative values | ||
// or there are no z-index declarations | ||
if (abort || !nodes.length) { | ||
return; | ||
} | ||
cache.optimizeValues(); // Second pass; optimize | ||
nodes.forEach(decl => { | ||
// Need to coerce to string so that the | ||
// AST is updated correctly | ||
decl.value = cache.getValue(decl.value).toString(); | ||
}); | ||
} | ||
}; | ||
} | ||
cache.optimizeValues(); // Second pass; optimize | ||
nodes.forEach(decl => { | ||
// Need to coerce to string so that the | ||
// AST is updated correctly | ||
decl.value = cache.getValue(decl.value).toString(); | ||
}); | ||
}; | ||
}); | ||
} | ||
pluginCreator.postcss = true; | ||
var _default = pluginCreator; | ||
exports.default = _default; | ||
module.exports = exports.default; |
{ | ||
"name": "postcss-zindex", | ||
"version": "4.0.0-nightly.2020.1.9", | ||
"version": "4.0.0-nightly.2020.1.11", | ||
"description": "Reduce z-index values with PostCSS.", | ||
@@ -27,3 +27,2 @@ "main": "dist/index.js", | ||
"has": "^1.0.3", | ||
"postcss": "^7.0.16", | ||
"uniqs": "^2.0.0" | ||
@@ -43,3 +42,9 @@ }, | ||
"node": ">=10.13.0" | ||
}, | ||
"devDependencies": { | ||
"postcss": "^8.2.1" | ||
}, | ||
"peerDependencies": { | ||
"postcss": "^8.2.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7089
85
1
+ Addednanoid@3.3.7(transitive)
+ Addedpicocolors@1.1.0(transitive)
+ Addedpostcss@8.4.47(transitive)
+ Addedsource-map-js@1.2.1(transitive)
- Removedpostcss@^7.0.16
- Removedpicocolors@0.2.1(transitive)
- Removedpostcss@7.0.39(transitive)
- Removedsource-map@0.6.1(transitive)