From 087b0774df5093a7687039110f59cbf2a78f903f Mon Sep 17 00:00:00 2001 From: Zach Green Date: Tue, 30 May 2017 18:19:28 -0400 Subject: [PATCH] fix multiplied critical output by setting atRule as container --- lib/getCriticalRules.js | 7 ++++--- package.json | 2 +- src/getCriticalRules.js | 14 ++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/getCriticalRules.js b/lib/getCriticalRules.js index e28f21d..961e314 100644 --- a/lib/getCriticalRules.js +++ b/lib/getCriticalRules.js @@ -71,11 +71,12 @@ function correctSourceOrder(root) { * @return {Object} A new root node with an atrule at its base. */ function establishContainer(node) { - return node.parent.type === 'atrule' && node.parent.name !== 'critical' ? updateCritical(_postcss2.default.atRule({ + return node.parent.type === 'atrule' && node.parent.name !== 'critical' ? _postcss2.default.atRule({ name: node.parent.name, type: node.parent.type, - params: node.parent.params - }), node) : node.clone(); + params: node.parent.params, + nodes: [node] + }) : node.clone(); } /** diff --git a/package.json b/package.json index 90c13ba..ae1a5f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-critical-css", - "version": "2.1.3", + "version": "2.1.4", "description": "Generate critical CSS using PostCSS", "main": "index.js", "repository": { diff --git a/src/getCriticalRules.js b/src/getCriticalRules.js index f562250..3fa4fb0 100644 --- a/src/getCriticalRules.js +++ b/src/getCriticalRules.js @@ -63,14 +63,12 @@ function correctSourceOrder (root: Object): Object { */ function establishContainer (node: Object): Object { return node.parent.type === 'atrule' && node.parent.name !== 'critical' - ? updateCritical( - postcss.atRule({ - name: node.parent.name, - type: node.parent.type, - params: node.parent.params - }), - node - ) + ? postcss.atRule({ + name: node.parent.name, + type: node.parent.type, + params: node.parent.params, + nodes: [node] + }) : node.clone() }