css-ast-iterations
Advanced tools
Comparing version
{ | ||
"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); |
49382
3.29%43
4.88%911
5.07%294
2.44%