Skip to content

Commit

Permalink
fix multiplied critical output by setting atRule as container
Browse files Browse the repository at this point in the history
  • Loading branch information
zgreen committed May 30, 2017
1 parent a59a90f commit 087b077
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
7 changes: 4 additions & 3 deletions lib/getCriticalRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
14 changes: 6 additions & 8 deletions src/getCriticalRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down

0 comments on commit 087b077

Please sign in to comment.