Skip to content

Commit

Permalink
Merge pull request #17 from zgreen/15-multiplied-output
Browse files Browse the repository at this point in the history
fix multiplied scope output
  • Loading branch information
zgreen authored May 31, 2017
2 parents be86fb9 + 7debd45 commit 8ae5205
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/getChildRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ function getChildRules(css, parent) {
name: atRule.name,
params: atRule.params
});
// Should append even if parent selector
if (rule.selector === parent.selector || childRule) {
/**
* Should append even if parent selector, but make sure the two rules
* aren't identical.
*/
if ((rule.selector === parent.selector || childRule) && _postcss2.default.parse(rule).toString() !== _postcss2.default.parse(parent).toString()) {
var clone = rule.clone();
criticalAtRule.append(clone);
result.push(criticalAtRule);
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.4",
"version": "2.1.5",
"description": "Generate critical CSS using PostCSS",
"main": "index.js",
"repository": {
Expand Down
10 changes: 8 additions & 2 deletions src/getChildRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ export function getChildRules (css: Object, parent: Object): Array<Object> {
name: atRule.name,
params: atRule.params
})
// Should append even if parent selector
if (rule.selector === parent.selector || childRule) {
/**
* Should append even if parent selector, but make sure the two rules
* aren't identical.
*/
if (
(rule.selector === parent.selector || childRule) &&
postcss.parse(rule).toString() !== postcss.parse(parent).toString()
) {
const clone = rule.clone()
criticalAtRule.append(clone)
result.push(criticalAtRule)
Expand Down

0 comments on commit 8ae5205

Please sign in to comment.