CSS AST iterations
😄💚🌲 Provide a very simple API for complex iterations on the CSS abstract syntax tree (AST).
Table of contents
- How to install
- Basic Example
- CSS AST reference
- Methods list
- Stylesheet Level - root
- findAllRules
- moonWalkAllRules
- findAllRulesByType
- findAllRulesBySelectors
- addRule
- removeRule
- findAllSelectors
- findAllImport
- findAllDeclarations
- findAllDeclarationsBySelectors
- findAllDeclarationsByProperty
- findAllDeclarationsByValue
- Rule Level
- findDeclarations
- findDeclarationsBySelectors
- findDeclarationsByProperty
- findDeclarationsByValue
- Declarations Level
- addDeclaration
- removeDeclaration
- getParam
- Stylesheet Level - root
- Development
- Versioning
- Contributing
- History
- License
How to install
$ npm install css --save$ npm install css-ast-iterations --save
Basic Example
const css = ;const addIterations = ; // Create the ASTconst stylesheet = css; // Add all methods for iterations; // Use a findRules method for find and iterates on all Rulesstylesheet;
CSS AST reference
View the CSS AST Explorer.
Methods list
Stylesheet Level - root
Find and iterates on all Rules:
stylesheet;
Find and iterates on all Rules (Backwards):
stylesheet;
Find and iterates on all Rules (filter by rule rules):
stylesheet;
Find and iterates on all Rules (filter by import rules):
stylesheet;
Find and iterates on all Rules (filter by comment rules):
stylesheet;
Find and iterates on all Rules (filter by selectors):
stylesheet;
Add a single rule:
stylesheet; //Rule position
Remove a single rule:
stylesheet; //Rule position
Find and iterates on all Selectors:
stylesheet;
Find and iterates on all imports:
stylesheet;
Find and iterates on all Declarations:
stylesheet;
Find and iterates on all Declarations (filter by selectors):
stylesheet;
Find and iterates on all Declarations (filter by property):
stylesheet;
Find and iterates on all Declarations (filter by value):
stylesheet;
Rule Level
Find and iterates on Declarations:
// Stylesheet Level (root)stylesheet;
Find and iterates on Declarations (filter by selectors):
// Stylesheet Level (root)stylesheet;
Find and iterates on Declarations (filter by property):
// Stylesheet Level (root)stylesheet;
Find and iterates on Declarations (filter by value):
// Stylesheet Level (root)stylesheet;
Declarations Level
Add a new declaration:
// Stylesheet Level (root)stylesheet;
Remove a declaration:
// Stylesheet Level (root)stylesheet;
Get a specific param from a value:
// Stylesheet Level (root)stylesheet;
Development
Code Style
Follow the NodeJS code style guide.
Validate the code style with ESLint:
$ npm run eslint
Tests
Run the unit tests with mocha:
$ npm test
Calculate the coverage with Istanbul:
$ npm run cover
Versioning
To keep better organization of releases we follow the Semantic Versioning 2.0.0 guidelines.
Contributing
Find on our issues the next steps of the project ;)
Want to contribute? Follow these recommendations.
History
See Releases for detailed changelog.