Skip to content

Commit d4c45b3

Browse files
committed
drop any leftover empty blocks, e.g. :root { }
1 parent 3f06d4c commit d4c45b3

12 files changed

+160
-159
lines changed

dist/dropcss.cjs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,8 @@ function postProc$1(out, shouldDrop, log, START) {
939939

940940
out = dropCssVars(out, shouldDrop);
941941

942-
return out;
942+
// kill any leftover empty blocks e.g. :root {}
943+
return out.replace(/[^{}]+\{\s*\}/gm, '');
943944
}
944945

945946
var ATTRIBUTES = /\[([\w-]+)(?:(.?=)"?([^\]]*?)"?)?\]/i;

dist/dropcss.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,8 @@
943943

944944
out = dropCssVars(out, shouldDrop);
945945

946-
return out;
946+
// kill any leftover empty blocks e.g. :root {}
947+
return out.replace(/[^{}]+\{\s*\}/gm, '');
947948
}
948949

949950
var ATTRIBUTES = /\[([\w-]+)(?:(.?=)"?([^\]]*?)"?)?\]/i;

dist/dropcss.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"devDependencies": {
2828
"mocha": "^6.1.4",
2929
"nyc": "^14.1.1",
30-
"rollup": "^1.12.5",
30+
"rollup": "^1.13.0",
3131
"rollup-plugin-buble": "^0.19.6",
3232
"rollup-plugin-cjs-es": "^0.7.0",
3333
"rollup-plugin-terser": "^5.0.0"

src/postproc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ function postProc(out, shouldDrop, log, START) {
151151

152152
LOGGING && log.push([+new Date() - START, 'Drop unused --* props']);
153153

154-
return out;
154+
// kill any leftover empty blocks e.g. :root {}
155+
return out.replace(/[^{}]+\{\s*\}/gm, '');
155156
}
156157

157158
exports.postProc = postProc;

test/bench/stress/output/dropcss.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/bench/stress/output/dropcss.pretty.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
:root{
2-
}
31
*,::after,::before{
42
box-sizing:border-box
53
}

0 commit comments

Comments
 (0)