Skip to content

Commit

Permalink
Made sure rebasing is truly aborted
Browse files Browse the repository at this point in the history
If a negative z-index isn’t the first z-index value, all z-index values
remain unchanged. Also, added a warning.
  • Loading branch information
niccai authored and ben-eb committed Feb 16, 2017
1 parent 792d43e commit 6074b01
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/postcss-zindex/index.js
Expand Up @@ -21,6 +21,11 @@ module.exports = postcss.plugin('postcss-zindex', function () {
nodes.push(decl);
cache.addValue(decl.value);
});

// Abort rebasing altogether due to z-index being found
if (abort) {
return;
}

cache.optimizeValues();

Expand Down
4 changes: 2 additions & 2 deletions packages/postcss-zindex/test.js
Expand Up @@ -45,8 +45,8 @@ var tests = [{
expected: 'h1{color:black;font-weight:bold}'
}, {
message: 'should abort early if any negative z-indices were found',
fixture: '.a{z-index:-2}.b{z-index:10}.c{z-index:8}.d{z-index:6}',
expected: '.a{z-index:-2}.b{z-index:10}.c{z-index:8}.d{z-index:6}'
fixture: '.a{z-index:8}.b{z-index:-2}.c{z-index:10}.d{z-index:8}.e{z-index:6}',
expected: '.a{z-index:8}.b{z-index:-2}.c{z-index:10}.d{z-index:8}.e{z-index:6}'
}];

function process (css, options) {
Expand Down

0 comments on commit 6074b01

Please sign in to comment.