Bug Tracker

Opened 12 years ago

Closed 12 years ago

#3803 closed bug (fixed)

if the ID of an element contains a dot ("."), it's ancestores are not selectable by tag

Reported by: ghum Owned by: john
Priority: major Milestone: 1.3
Component: selector Version: 1.2.6
Keywords: regression escaped dot id ancestors Cc:
Blocked by: Blocking:



within 1.2.6 $("#i7922
.dxa input") selects all input-elements below the element with the ID i7922.dxa

within 1.3.beta1 $("#i7922
.dxa input") does not select any input element below the element with "i7922.dxa"

For elements WITHOUT an escaped "." all is still fine.

The attached sample demonstrates the problem

Attachments (1)

jq13bug.html (1.9 KB) - added by ghum 12 years ago.
Sample file to reproduce the described bug

Download all attachments as: .zip

Change History (4)

Changed 12 years ago by ghum

Attachment: jq13bug.html added

Sample file to reproduce the described bug

comment:1 Changed 12 years ago by balazs.endresz

The problem is that preFilter.ID simply returns match[1], which still contains an unnecessary backslash so it won't match the item's id afterwards. Removing these backslashes in preFilter solves it:

jQuery.expr.preFilter.ID = function(match){
  return match[1].replace(/\\(.)/,"$1");

comment:2 Changed 12 years ago by balazs.endresz

I've just had a look at http://github.com/jeresig/sizzle/commit/88edec547d5f5e0979c86a0ab5e872adcb0f2a7a and the modified class preFilter: so because IDs can't contain a backslash and I forgot the global modifier this would work better:

jQuery.expr.preFilter.ID = function(match){
  return match[1].replace(/\\/g,"");

Though I'm not sure if classes can contain a backslash or not: http://www.w3.org/TR/REC-html40/struct/global.html#h-7.5.2

comment:3 Changed 12 years ago by john

Resolution: fixed
Status: newclosed
Version: 1.2.6

Yeah, they were already being removed from the class filters but not ID, should be fixed now: http://github.com/jeresig/sizzle/commit/6bb75a1f136d30fa5d8486f5aa1fc7e5ed08d9b2

Note: See TracTickets for help on using tickets.