Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue occurred with Angular js selectors #2

Open
Jayaramki opened this issue May 19, 2016 · 1 comment
Open

Issue occurred with Angular js selectors #2

Jayaramki opened this issue May 19, 2016 · 1 comment
Assignees

Comments

@Jayaramki
Copy link

Hi @Kaiido,

I am using angular js in my page. So, basically angular will add directives like 'ng:cloak', 'ng-cloak', 'data-ng-cloak', 'x-ng-cloak', '.ng-cloak', '.x-ng-cloak', '.ng-hide' the following selectors to page.

SVG2Bitmap.js:294 Uncaught SyntaxError: Failed to execute 'matches' on 'Element': '[ng:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak, .ng-hide' is not a valid selector.

Now I am getting the above error while creating a image from SVG.

@Kaiido
Copy link
Owner

Kaiido commented May 26, 2016

Sorry @Jayaramki it took me so long to see your issue...

This error seems strange to me :
[ng:cloack] is indeed an invalid CSS attribute selector. For namespaced attributes it should be :

@namespace ng "http://someNameSpaceURI";
[ng|cloak] { ruleset: ...;}

So a few questions come to my mind :

  • Which browser does throw this error ? Your browser should have rejected this ruleset, and SVG2Bitmap script shouldn't have been able to see it.
  • I don't know AngularJS so much, so are you sure it is this library which added this ruleset and not you in your CSS files ? And if so, could create a small snippet where the problem does occur so I can see it live ?

For a quick fix, you could probably just add selector = selector.replace(/:/g,'\\:') @line300 of the latest version

var selector = rules[j].selectorText;
// probably an external stylesheet we can't access
if(!selector){
    continue;
 }
selector = selector.replace(/:/g,'\\:')
// is it our svg node or one of its children ?
if ((svg.matches && svg.matches(selector)) || svg.querySelector(selector)) { ...

But I would probably have to make a real css-selectors validator, and a CSS namespace parser, but I prefer to have the previously requested informations before committing this quick fix.

@Kaiido Kaiido self-assigned this Jun 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants