You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

css-ast-iterations

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-ast-iterations - npm Package Compare versions

Comparing version

to
0.2.0

src/core/findAllRulesBySelectors.js

2

package.json
{
"name": "css-ast-iterations",
"description": "Provide a very simple API for complex iterations on the CSS abstract syntax tree (AST).",
"version": "0.1.1",
"version": "0.2.0",
"author": {

@@ -6,0 +6,0 @@ "name": "afonsopacifer",

@@ -93,2 +93,9 @@ # CSS AST iterations

*Find and iterates on all Rules (filter by selectors):*
```js
stylesheet.findAllRulesBySelectors('.foo', (rule, ruleIndex) => {
console.log(rule);
});
```
*Find and iterates on all Selectors:*

@@ -95,0 +102,0 @@ ```js

@@ -11,3 +11,3 @@ const addDeclaration = (astRoot) => {

if (rule.type === 'rule') {
rule.declarations.forEach((declaration) => {
rule.declarations.forEach(() => {

@@ -14,0 +14,0 @@ rule.addDeclaration = function(property, value, index) {

@@ -11,3 +11,3 @@ const removeDeclaration = (astRoot) => {

if (rule.type === 'rule') {
rule.declarations.forEach((declaration) => {
rule.declarations.forEach(() => {

@@ -14,0 +14,0 @@ rule.removeDeclaration = function(index) {

@@ -6,2 +6,3 @@ /* eslint max-len: ["error", 100, 2] */

const findAllRulesByType = require('./core/findAllRulesByType');
const findAllRulesBySelectors = require('./core/findAllRulesBySelectors');
const findAllSelectors = require('./core/findAllSelectors');

@@ -30,2 +31,3 @@ const findAllImport = require('./core/findAllImport');

findAllRulesByType(astRoot);
findAllRulesBySelectors(astRoot);
findAllSelectors(astRoot);

@@ -48,4 +50,5 @@ findAllImport(astRoot);

getParam(astRoot);
};
module.exports = addIterations;

@@ -35,3 +35,3 @@ /* eslint max-len: ["error", 100, 2] */

rule.findDeclarationsByProperty('width', (declaration) => {
rule.findDeclarationsByProperty('width', () => {

@@ -38,0 +38,0 @@ rule.addDeclaration('background', '#fff', 0);

// Stylesheet Level (root)
require('./findAllRules.test.js');
require('./findAllRulesByType.test.js');
require('./findAllRulesBySelectors.test.js');
require('./findAllSelectors.test.js');

@@ -5,0 +6,0 @@ require('./findAllImport.test.js');

@@ -36,3 +36,3 @@ /* eslint max-len: ["error", 100, 2] */

rule.findDeclarationsByProperty('width', (declaration) => {
rule.findDeclarationsByProperty('width', () => {

@@ -39,0 +39,0 @@ rule.removeDeclaration(0);