jotform / css.js

A lightweight, battle tested, fast, CSS parser in JavaScript
https://medium.com/jotform-form-builder/writing-a-css-parser-in-javascript-3ecaa1719a43
MIT License
426 stars 63 forks source link

how to modify parsed css? #31

Open aloksharma1 opened 4 years ago

aloksharma1 commented 4 years ago

hi, i have a requirement where i want to modify the parsed css and then replace it in style tag, for example:

<style id="customCss">
.someClass {
  margin : 20px;  
}
@media (max-width: 600px) {
  .someClass {
  margin : 5px;  
}
}
</style>

i want to parse rule without media query, and modify it and then replace it back in style tag, how to achieve that?

basically i want this to turn into following output:

<style id="customCss">
.someClass {
  margin : 10px;  
  padding:5px;
}
@media (max-width: 600px) {
  .someClass {
  margin : 5px;  
  padding:0;
}
}
</style>