jquery / sizzle

A sizzlin' hot selector engine.

Home Page:https://sizzlejs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Syntax error, unrecognized expression when id has angular braces in it

Jothay opened this issue · comments

We're using Angular 1.x which includes jQuery which includes sizzle. We're getting an error from sizzle because we have an ng-repeat that creates objects with dynamic ids in the format of #menuActionsLineItem{{item.ID}}_mn_active The braces are causing console errors. We need a way to let it know the compiled HTML result (which is what actually ends up on the page) so this stops.

The errors are correct; #menuActionsLineItem{{item.ID}}_mn_active is not a valid selector. It should be #menuActionsLineItem\{\{item\.ID\}\}_mn_active, which you can get with Sizzle.escape like "#" + jQuery.escapeSelector("menuActionsLineItem{{item.ID}}_mn_active").

First, dude, give me a chance to respond before closing the ticket.

Second, I can't escape that stuff, this is for Angular. I'm not actually looking for #menuActionsLineItem{{item.ID}}_mn_active anywhere, it gets resolved before the HTML ends up in the page as something like #menuActionsLineItem99999_mn_active where 99999 is the item.ID which is dynamic per the ng-repeat data from Angular. Somehow, Sizzle is getting a hold of the pre-compiled version with braces in it still, which is then throwing an error. I need to find a way to make Sizzle stop doing that and use the resolved version (that won't have braces but will have a number instead which should all be valid). I stress that I am not in any way intentionally using Sizzle at all, it's only there because it's been included by npm when installing Angular 1.4.8. As it is there, this is something I will have to deal with and am asking for some guidance from the Sizzle team on what could be causing the problem and how I might go about solving it.

Ok, but that still wouldn't be jQuery's problem. Sizzle can't be responsible for compiling template strings for you, especially when it doesn't know what value to use or what templating language it is. We also can't tell you how it's getting to Sizzle without debugging your application for you. This is more of a support question than a bug report.

This is more of a support question than a bug report.

Ok, where would I go to get the support for it then? I'll gladly punt over to the support queue instead.

I don't know how it's getting my templated HTML instead of the resulted HTML, I don't need or want Sizzle to do anything really, I'd rather Angular took care of everything, but because of the reference paths, it's physically in my page and grabbing this somehow so I'm not sure what to do about it.

GitHub is not a place to get free support. You should look on various online communities like Stack Overflow. If it turns out there's a real issue and not just something wrong in your code you can report an issue, though in this case this would be an AngularJS issue, not a jQuery or Sizzle one. But it doesn't seem you're at that point yet.