0

I am trying to make a match of the selector and the element to extract relevant css, it works well except for certain types of selectors implemented because of angular on certain sites

    var ruleCheck='[ng:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak, .ng-hide:not(.ng-hide-animate)';

  //the issue is with selectors as [ng:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak] throws an error of invalid selector

var ruleCheck1='.ng-cloak, .x-ng-cloak, .ng-hide:not(.ng-hide-animate)';

//the above ruleCheck1 works fine



    var a= document.createElement("p");
    p.className="test";
    a.matches(ruleCheck1);// works fine
    a.matches(ruleCheck); // invalid selector error 

Is there a workaround for this problem

melwyn pawar
  • 1,766
  • 2
  • 16
  • 21
  • Looks like it's the `[ng:cloak]` in particular, specifically the `:` in it, that's throwing the error. – James Thorpe Mar 08 '16 at 09:53
  • I'm not sure, but I was thinking of having a good regex to replace [xyz] and smartly ignore cases as div[class*="test"] like many attribute selectors. I'm still not sure about the repercussions – melwyn pawar Mar 08 '16 at 09:58

0 Answers0