Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.0.0 to 3.1.0

tests/case.css

55

index.js

@@ -21,11 +21,3 @@ module.exports = function (stylecow) {

selectors.forEach(function (selector) {
var mergedSelector = parentSelector.clone();
merge(mergedSelector, selector[0].clone());
selector.slice(1).forEach(function (element) {
mergedSelector.push(element.clone());
});
mergedSelectors.push(mergedSelector);
mergedSelectors.push(merge(parentSelector.clone(), selector.clone()));
});

@@ -46,27 +38,40 @@ });

function merge (selector, element) {
if (element[0].name !== '&') {
return selector.push(element);
function merge (selector, appendedSelector) {
var firstElement = appendedSelector.shift();
// html { .foo { => html .foo
if (firstElement.type !== 'Combinator') {
var separator = new stylecow.Combinator();
separator.name = ' ';
selector.push(separator);
selector.push(firstElement);
}
// html { >.foo { => html>.foo
else if (firstElement.name !== '&') {
selector.push(firstElement);
}
element[0].remove();
// .foo { &html { => html.foo
else if (appendedSelector.length && (appendedSelector[0].is({
type: 'Keyword',
name: /^\w/
}))) {
firstElement = appendedSelector.shift();
if (element.length) {
var prevElement = selector.slice(-1)[0];
var curr = element.shift();
var combinators = selector.children('Combinator');
if (curr.is({
type: 'Keyword',
name: /^\w/
})) {
prevElement.unshift(curr);
if (combinators.length) {
combinators.pop().after(firstElement);
} else {
prevElement.push(curr);
selector.unshift(firstElement);
}
}
element.forEach(function (child) {
prevElement.push(element);
});
while (appendedSelector[0]) {
selector.push(appendedSelector[0]);
}
return selector;
}
};
{
"name": "stylecow-plugin-nested-rules",
"description": "Stylecow plugin to add support for nested rules.",
"version": "3.0.0",
"version": "3.1.0",
"author": "Oscar Otero <oom@oscarotero.com>",

@@ -12,4 +12,7 @@ "homepage": "https://github.com/stylecow/stylecow-plugin-nested-rules",

},
"devDependencies": {
"stylecow": "*"
},
"main": "index.js",
"license": "MIT"
}
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