From 0651f3046a75e847b3b7fb1bb9172e4fd1302a68 Mon Sep 17 00:00:00 2001 From: Christian Marienfeld Date: Sun, 8 Oct 2017 15:32:06 +0200 Subject: [PATCH 1/2] stringify css rules with empty declarations --- lib/stringify/compress.js | 2 +- lib/stringify/identity.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/stringify/compress.js b/lib/stringify/compress.js index 929b4a21..1ee2755e 100644 --- a/lib/stringify/compress.js +++ b/lib/stringify/compress.js @@ -181,7 +181,7 @@ Compiler.prototype['custom-media'] = function(node){ Compiler.prototype.rule = function(node){ var decls = node.declarations; - if (!decls.length) return ''; + if (!decls.length) decls = ''; return this.emit(node.selectors.join(','), node.position) + this.emit('{') diff --git a/lib/stringify/identity.js b/lib/stringify/identity.js index b390c91e..0661788e 100644 --- a/lib/stringify/identity.js +++ b/lib/stringify/identity.js @@ -218,7 +218,7 @@ Compiler.prototype['custom-media'] = function(node){ Compiler.prototype.rule = function(node){ var indent = this.indent(); var decls = node.declarations; - if (!decls.length) return ''; + if (!decls.length) decls = ''; return this.emit(node.selectors.map(function(s){ return indent + s }).join(',\n'), node.position) + this.emit(' {\n') From f0d3eca33fb995deadbb406788a59084c15f4db8 Mon Sep 17 00:00:00 2001 From: Christian Marienfeld Date: Sun, 8 Oct 2017 15:38:38 +0200 Subject: [PATCH 2/2] ignore rules with empty selectors --- lib/stringify/compress.js | 1 + lib/stringify/identity.js | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/stringify/compress.js b/lib/stringify/compress.js index 1ee2755e..7c0b8dfb 100644 --- a/lib/stringify/compress.js +++ b/lib/stringify/compress.js @@ -180,6 +180,7 @@ Compiler.prototype['custom-media'] = function(node){ */ Compiler.prototype.rule = function(node){ + if (!node.selectors.length) { return ''; } var decls = node.declarations; if (!decls.length) decls = ''; diff --git a/lib/stringify/identity.js b/lib/stringify/identity.js index 0661788e..e10768ed 100644 --- a/lib/stringify/identity.js +++ b/lib/stringify/identity.js @@ -216,6 +216,7 @@ Compiler.prototype['custom-media'] = function(node){ */ Compiler.prototype.rule = function(node){ + if (!node.selectors.length) { return ''; } var indent = this.indent(); var decls = node.declarations; if (!decls.length) decls = '';