I'm using Tailwind CSS alongsid vanilla JS and I'm trying to get some specific nodes via a built selector. Problem : the selector is marked as invalid when the code executed by the browser (bundled in Webpack) but I can make it work in the web console.
Here is a reproductible sample; the problems seems to be around the w-2/4 containing a / so I'm escaping it to make it like \\/. Taking any idea to fix this ...
const prefix = '.';
const width = 'w-2/4';
const rounded = 'rounded';
const selector = prefix + width + prefix + rounded;
parsed = selector.replace('/', '\\\\/');
console.log(parsed);
const matches = document.querySelectorAll('.w-2\\/4.rounded');
console.log(matches);
const broken = document.querySelectorAll(parsed);
console.log(broken);
<h3 class="inline-block statlib-kpi-value text-2xl h-4 bg-blue-400 rounded w-2/4 "></h3>
Answered by @biberman, thanks to him.