stylecow-plugin-nested-rules
Advanced tools
Comparing version 3.2.1 to 4.0.0
36
index.js
@@ -12,4 +12,4 @@ module.exports = function (stylecow) { | ||
parentRule | ||
.firstChild({type: 'Block'}) | ||
.children() | ||
.getChild('Block') | ||
.getChildren() | ||
.forEach(function (child) { | ||
@@ -30,3 +30,3 @@ | ||
if (!parentRule.firstChild('Block').length) { | ||
if (!parentRule.getChild('Block').length) { | ||
parentRule.remove(); | ||
@@ -40,11 +40,9 @@ } | ||
rule.push(parentRule.firstChild('Selectors').clone()); | ||
rule.push(media.firstChild('Block')); | ||
rule.push(parentRule.getChild('Selectors').clone()); | ||
rule.push(media.getChild('Block')); | ||
var block = new stylecow.Block(); | ||
block.push(rule); | ||
media.push(block); | ||
var index = rule.index(); | ||
@@ -54,4 +52,4 @@ var offset = 1; | ||
rule | ||
.firstChild({type: 'Block'}) | ||
.children('Rule') | ||
.getChild('Block') | ||
.getChildren('Rule') | ||
.forEach(function (child) { | ||
@@ -62,15 +60,15 @@ nestedRule(rule, child, index + offset); | ||
if (rule.firstChild('Block').length === 0) { | ||
if (rule.getChild('Block').length === 0) { | ||
rule.remove(); | ||
} | ||
parentRule.parent().splice(parentRuleIndex, 0, media); | ||
parentRule.getParent().splice(parentRuleIndex, 0, media); | ||
} | ||
function nestedRule(parentRule, rule, parentRuleIndex) { | ||
var selectors = rule.firstChild({type: 'Selectors'}); | ||
var selectors = rule.getChild('Selectors'); | ||
var mergedSelectors = new stylecow.Selectors(); | ||
parentRule | ||
.firstChild({type: 'Selectors'}) | ||
.getChild('Selectors') | ||
.forEach(function (parentSelector) { | ||
@@ -83,3 +81,3 @@ selectors.forEach(function (selector) { | ||
selectors.replaceWith(mergedSelectors); | ||
parentRule.parent().splice(parentRuleIndex, 0, rule); | ||
parentRule.getParent().splice(parentRuleIndex, 0, rule); | ||
} | ||
@@ -92,4 +90,3 @@ | ||
if (firstElement.type !== 'Combinator') { | ||
var separator = new stylecow.Combinator(); | ||
separator.name = ' '; | ||
var separator = (new stylecow.Combinator()).setName(' '); | ||
selector.push(separator); | ||
@@ -105,9 +102,6 @@ selector.push(firstElement); | ||
// .foo { &html { => html.foo | ||
else if (appendedSelector.length && (appendedSelector[0].is({ | ||
type: 'Keyword', | ||
name: /^\w/ | ||
}))) { | ||
else if (appendedSelector.length && appendedSelector[0].is('TypeSelector')) { | ||
firstElement = appendedSelector.shift(); | ||
var combinators = selector.children('Combinator'); | ||
var combinators = selector.getChildren('Combinator'); | ||
@@ -114,0 +108,0 @@ if (combinators.length) { |
{ | ||
"name": "stylecow-plugin-nested-rules", | ||
"description": "Stylecow plugin to add support for nested rules.", | ||
"version": "3.2.1", | ||
"version": "4.0.0", | ||
"author": "Oscar Otero <oom@oscarotero.com>", | ||
@@ -12,10 +12,10 @@ "homepage": "https://github.com/stylecow/stylecow-plugin-nested-rules", | ||
}, | ||
"devDependencies": { | ||
"stylecow": "6.*" | ||
}, | ||
"scripts": { | ||
"test": "node tests/index.js" | ||
"test": "mocha tests/cases.js" | ||
}, | ||
"devDependencies": { | ||
"stylecow": "*" | ||
}, | ||
"main": "index.js", | ||
"license": "MIT" | ||
} |
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
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
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
24155
12
863
0
1