stylecow-plugin-nested-rules
Advanced tools
Comparing version 3.2.0 to 3.2.1
49
index.js
@@ -8,15 +8,2 @@ module.exports = function (stylecow) { | ||
fn: function (parentRule) { | ||
// resolve nested @media | ||
parentRule | ||
.firstChild({type: 'Block'}) | ||
.children({ | ||
type: 'AtRule', | ||
name: 'media' | ||
}) | ||
.forEach(function (media) { | ||
nestedMedia(parentRule, media); | ||
}); | ||
// resolve nested rules | ||
var index = parentRule.index(); | ||
@@ -27,6 +14,16 @@ var offset = 1; | ||
.firstChild({type: 'Block'}) | ||
.children('Rule') | ||
.children() | ||
.forEach(function (child) { | ||
nestedRule(parentRule, child, index + offset); | ||
++offset; | ||
// resolve nested @media | ||
if (child.type === 'AtRule' && child.name === 'media') { | ||
nestedMedia(parentRule, child, index + offset); | ||
++offset; | ||
} | ||
// resolve nested rules | ||
else if (child.type === 'Rule') { | ||
nestedRule(parentRule, child, index + offset); | ||
++offset; | ||
} | ||
}); | ||
@@ -40,3 +37,3 @@ | ||
function nestedMedia(parentRule, media) { | ||
function nestedMedia(parentRule, media, parentRuleIndex) { | ||
var rule = new stylecow.Rule(); | ||
@@ -52,3 +49,19 @@ | ||
parentRule.after(media); | ||
var index = rule.index(); | ||
var offset = 1; | ||
rule | ||
.firstChild({type: 'Block'}) | ||
.children('Rule') | ||
.forEach(function (child) { | ||
nestedRule(rule, child, index + offset); | ||
++offset; | ||
}); | ||
if (rule.firstChild('Block').length === 0) { | ||
rule.remove(); | ||
} | ||
parentRule.parent().splice(parentRuleIndex, 0, media); | ||
} | ||
@@ -55,0 +68,0 @@ |
{ | ||
"name": "stylecow-plugin-nested-rules", | ||
"description": "Stylecow plugin to add support for nested rules.", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"author": "Oscar Otero <oom@oscarotero.com>", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/stylecow/stylecow-plugin-nested-rules", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
6773
179
0