Skip to main content

Bug Tracker

Side navigation

#11146 closed bug (invalid)

Opened January 09, 2012 09:03PM UTC

Closed January 09, 2012 09:10PM UTC

Last modified May 31, 2012 03:28PM UTC

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:
Blocked by: Blocking:
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.

Attachments (0)
Change History (5)

Changed January 09, 2012 09:07PM UTC by aishwar.muthuraman comment:1

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.

Changed January 09, 2012 09:10PM UTC by timmywil comment:2

component: unfiledselector
priority: undecidedlow
resolution: → invalid
status: newclosed

The exclamation point must be escaped.

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

Changed May 31, 2012 03:26PM UTC by anonymous comment:3

Replying to [comment:2 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 == "!--"){}

Changed May 31, 2012 03:27PM UTC by anonymous comment:4

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 == "!--"){}

Changed May 31, 2012 03:28PM UTC by dmethvin comment:5

You should ask for help on the forum!