From 0ad4be6a62dd12fcafa31f3faa2c101cc0ea25f0 Mon Sep 17 00:00:00 2001 From: Nathan Hardy Date: Thu, 4 Feb 2021 11:44:32 +1100 Subject: [PATCH] Move empty declaration check after mapping --- src/styleSheetSerializer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/styleSheetSerializer.js b/src/styleSheetSerializer.js index 898b616..727f01f 100644 --- a/src/styleSheetSerializer.js +++ b/src/styleSheetSerializer.js @@ -56,9 +56,10 @@ const getAllRules = (rules, classNames) => rules .filter( rule => rule.type === 'media' || rule.type === 'supports' - || (rule.type === 'rule' && includesClassNames(classNames, rule.selectors) && rule.declarations.length) + || (rule.type === 'rule' && includesClassNames(classNames, rule.selectors)) ) - .map(rule => (rule.type === "rule" ? rule : Object.assign({}, rule, { rules: getAllRules(rule.rules, classNames) }))); + .map(rule => (rule.type === "rule" ? rule : Object.assign({}, rule, { rules: getAllRules(rule.rules, classNames) }))) + .filter(rule => (rule.type === "rule" && rule.declarations.length) || rule.rules.length); const getStyle = classNames => { const ast = getCSS();