0

I tried to use Modernizr, but it seems not to support this feature detection. I also read that it is difficult or even inmpossible to access pseudoclasses from javascript, because they are not part of DOM. So, after surfing the web I found no relevant information. I need an easy solution without the need to download heavy libraries. Can anybody help me with this?

Thanks

Sam Hanley
  • 4,707
  • 7
  • 35
  • 63
  • Related - http://stackoverflow.com/questions/21094865/test-if-a-browser-supports-a-css-selector – Harry Sep 17 '14 at 14:24

1 Answers1

0

Trap an error from querySelector or matches, which parses the selector and throws an error if it is not valid:

function invalid_pseudoclass_support () {
    var support = true;
    try {
        document.querySelector(':invalid');
    } catch (e) {
        support = false;
    }
    return support;
}