Bug Tracker

Modify

Ticket #3803 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

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

Description

regression:

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

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

Change History

Changed 4 years ago by ghum

Sample file to reproduce the described bug

comment:1 Changed 4 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 4 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 4 years ago by john

  • Status changed from new to closed
  • Version set to 1.2.6
  • Resolution set to fixed

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

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.