How to detect support for CSS pseudo-classes with vanilla JavaScript in your browser
At some point you may need to know whether a CSS pseudo-class is supported by the browser. I once did, with :autofill versus :-webkit-autofill.

At some point you may need to know whether a CSS pseudo-class is supported by the browser. I once did, with the :autofill property versus :-webkit-autofill, and now I'll tell you how I solved it.
Thanks to the :autofill property you can always apply a different style to an element such as an <input type="email"> or <input type="password"> once it has been autofilled, as in the typical login form.
In my work I needed to detect via JavaScript, only when the input is autofilled, but there is no JS event of the “autofill” kind. There is a way, a somewhat more sophisticated way of tackling the problem, devised by Tommy Brunn with the animationstart event but it never quite fitted for me.
The supportPseudoClass module
Browsing Stack Overflow, a user shared a very simple function to detect when a pseudo-class is supported.

