Socket
Socket
Sign inDemoInstall

stylecow-plugin-nested-rules

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylecow-plugin-nested-rules - npm Package Compare versions

Comparing version 3.2.1 to 4.0.0

tests/cases.js

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc