postcss-zindex
Advanced tools
Comparing version
@@ -0,1 +1,6 @@ | ||
# 2.1.0 | ||
* Now aborts early when encountering negative indices, making the transform | ||
safer overall. | ||
# 2.0.1 | ||
@@ -2,0 +7,0 @@ |
10
index.js
@@ -9,4 +9,14 @@ 'use strict'; | ||
var nodes = []; | ||
var abort = false; | ||
// First pass; cache all z indexes | ||
css.walkDecls('z-index', function (decl) { | ||
if (abort) { | ||
return; | ||
} | ||
// Check that no negative values exist. Rebasing is only | ||
// safe if all indices are positive numbers. | ||
if (decl.value[0] === '-') { | ||
abort = true; | ||
return; | ||
} | ||
nodes.push(decl); | ||
@@ -13,0 +23,0 @@ cache.addValue(decl.value); |
{ | ||
"name": "postcss-zindex", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Reduce z-index values with PostCSS.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -50,5 +50,7 @@ # [postcss][postcss]-zindex [][ci] [][npm] [][deps] | ||
Note that this module does not attempt to normalize relative z-index values, | ||
such as `-1`. Be careful with using this module alongside JavaScript injected | ||
CSS; ideally you should have already extracted all of your stacking context | ||
into CSS. | ||
such as `-1`; indeed, it will abort immediately when encountering these values | ||
as it cannot be sure that rebasing mixed positive & negative values will keep | ||
the stacking context intact. Be careful with using this module alongside | ||
JavaScript injected CSS; ideally you should have already extracted all of your | ||
stacking context into CSS. | ||
@@ -55,0 +57,0 @@ ## Usage |
7008
9.38%77
14.93%74
2.78%