Bug Tracker

Modify

Ticket #11146 (closed bug: invalid)

Opened 18 months ago

Last modified 13 months ago

Exclamation in id selector does not match the matching element

Reported by: aishwar.muthuraman Owned by:
Priority: low Milestone: None
Component: selector Version: 1.7.1
Keywords: Cc:
Blocking: Blocked by:

Description

When an element's id contains an exclamation mark, the jQuery id selector does not match it, while document.getElementById matches it.

See  http://jsfiddle.net/MKP43/1/ for example.

e.g. $('#abc!1') will always match nothing.

Change History

comment:1 Changed 18 months ago by aishwar.muthuraman

I did debug this and this will fix it:

Changing

quickExpr

to

/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([^\s][^\s]*)$)/

The above expression satisfies the HTML5 spec for ids:  http://dev.w3.org/html5/spec/Overview.html#the-id-attribute

Ids should contain atleast one character and should not contain spaces.

comment:2 follow-up: ↓ 3 Changed 18 months ago by timmywil

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to selector

The exclamation point must be escaped.

 http://jsfiddle.net/timmywil/MKP43/2/

comment:3 in reply to: ↑ 2 Changed 13 months ago by anonymous

Replying to timmywil:

The exclamation point must be escaped.

 http://jsfiddle.net/timmywil/MKP43/2/

I have the same issue! Im trying to use jquery to select a tag with <a href="#">!--</a> inside, and this is not working out.

For example if (a == "!--"){}

comment:4 Changed 13 months ago by anonymous

I have the same issue! Im trying to use jquery to select a tag with <a href="#">!--</a> inside, and this is not working out.

For example if (a == "!--"){}

comment:5 Changed 13 months ago by dmethvin

You should ask for help on the forum!

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.