Skip to content

Commit

Permalink
Don't fuse strings around and between packed rules
Browse files Browse the repository at this point in the history
Just leave everything to PostCSS. This could fix #17. This fixed test
also resolve #18.
  • Loading branch information
Kyo Nagashima committed Aug 28, 2014
1 parent b24bee2 commit e6ae50f
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 33 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ Becomes:
.foo {
width: 100px;
}

.baz {
width: 300px;
}
Expand Down
19 changes: 0 additions & 19 deletions lib/css-mqpacker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,6 @@

var postcss = require('postcss');

var _fuseStrings = function (a, b) {
var i = 0;
var s = '';
var j = 0;

for (i = b.length; i > 0; i--) {
s = b.substring(0, i);
j = a.lastIndexOf(s);

if (j >= 0 && j + s.length === a.length) {
break;
}
}

return a + b.substring(i);
};

var _process = function (css) {
var queries = {};
var params = [];
Expand All @@ -32,11 +15,9 @@ var _process = function (css) {
var past = queries[query];

if (typeof past === 'object') {
rule.first.before = _fuseStrings(_fuseStrings(past.after, rule.before), rule.first.before);
rule.each(function (r) {
past.append(r);
});
past.after = rule.after;
} else {
queries[query] = rule;
params.push(query);
Expand Down
3 changes: 1 addition & 2 deletions test/expected/between-the-packed-rules.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

@media (min-width: 999px) {
.foo {
z-index: 1;
}

.bar {
z-index: 2;
}

.baz {
z-index: 3;
}
Expand Down
6 changes: 0 additions & 6 deletions test/expected/multi.css
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
@charset "UTF-8";

@media (min-width: 99px) {
.foo {
z-index: 1;
}

.bar {
z-index: 2;
}
}

@media (min-width: 999px) {
.baz {
z-index: 3;
}

.qux {
z-index: 4;
}
}

@media screen and (min-width: 999px) {
.quux {
z-index: 5;
}

.corge {
z-index: 6;
}
Expand Down
3 changes: 0 additions & 3 deletions test/expected/query-order.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
@charset "UTF-8";

@media (min-width: 99px) {
.foo {
z-index: 1;
}

.bar {
z-index: 2;
}
}

@media (min-width: 999px) {
.foo {
z-index: 3;
Expand Down
2 changes: 0 additions & 2 deletions test/expected/simple.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
.foo {
z-index: 4;
}

.bar {
z-index: 5;
}

.baz {
z-index: 6;
}
Expand Down

0 comments on commit e6ae50f

Please sign in to comment.