0
# myfile.module.css
.btn{...}

I want to create new .js file as selectorPresent.js which has following things to do:

export function isSelectorPresent(filePathWithName, selector){
  //Return true if class is present in myfile.module.css else false
}

Example : isSelectorPresent(../myfile.module.css., btn). I want to see true here. I checked document.styleSheets but it seems that it's in browser level and module.css changed the classnames there.

Pankaj
  • 23
  • 3
  • If you're importing CSS modules with `import css from "../myfile.module.css"`, I think you can just do: `const isSelectorPresent = (cssModule, selector) => selector in cssModule;` (or `!!cssModule[selector]`), and then: `isSelectorPresent(myFileModule, ".btn");`, I'm not quite sure. – Rick Stanley Aug 06 '21 at 17:46

0 Answers0