Skip to content

Comments

Fixing issue for attributes with dot#95

Open
dondurivan wants to merge 1 commit intoarthurgouveia:masterfrom
dondurivan:master
Open

Fixing issue for attributes with dot#95
dondurivan wants to merge 1 commit intoarthurgouveia:masterfrom
dondurivan:master

Conversation

@dondurivan
Copy link

Adding single quotes fixes the error when there is dot in attribute.

In my case:
for=flat.flat was returning Uncaught Error: Syntax error, unrecognized expression: [for=flat.flat]

Adding quotes fixed it.

@rtelicak
Copy link

Hi,

I have similar problem, but there are many more special characters which cause selector not to work properly, like
, : [
see jquery selectors docs right at the beginning

so I'd go with escaping selector first, then use it as usually

// escape possible special characters in selector
elLabelId = elLabelId.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&')

tried it with

<input id="[a." type="checkbox">
<input id="a.b." type="checkbox">
<input id="asd!*" type="checkbox">
<input id="!@##$%^%&^&*)" type="checkbox">

and worked well.

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

Successfully merging this pull request may close these issues.

3 participants