Skip to main content

Bug Tracker

Side navigation

#3803 closed bug (fixed)

Opened January 07, 2009 12:39PM UTC

Closed January 11, 2009 02:11PM UTC

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:
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 (1)
  • jq13bug.html (1.9 KB) - added by ghum January 07, 2009 12:40PM UTC.

    Sample file to reproduce the described bug

Change History (3)

Changed January 09, 2009 04:39PM UTC by balazs.endresz comment:1

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");
}

Changed January 10, 2009 09:27AM UTC by balazs.endresz comment:2

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

Changed January 11, 2009 02:11PM UTC by john comment:3

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