Skip to content

Commit

Permalink
Merge pull request #16 from zgreen/15-multiplied-output
Browse files Browse the repository at this point in the history
fix multiplied critical output by setting atRule as container
  • Loading branch information
zgreen authored May 30, 2017
2 parents a59a90f + 4d50e92 commit be86fb9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 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
3 changes: 1 addition & 2 deletions 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 All @@ -19,7 +19,6 @@
"author": "Zach Green",
"license": "MIT",
"devDependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.11.4",
"babel-eslint": "^7.2.3",
"babel-plugin-transform-flow-strip-types": "^6.8.0",
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 be86fb9

Please sign in to comment.