Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#8021 closed bug (duplicate)

Possible regression: Finding elements doesn't work if context elements' id contains dot

Reported by: mikioma Owned by:
Priority: high Milestone: 1.5
Component: selector Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:


The "$(css, context)" syntax to find elements inside the "context" element doesn't work on jQuery 1.4.4 if the context element's id contains a dot character.

It works on 1.4.2 though!!!

You can use this test page:

  <script type="text/javascript" src="jquery-1.4.4.min.js"></script>
  <script type="text/javascript">
    function test()
      var dotted = document.getElementById("Dotted.Id");
      var undotted = document.getElementById("UndottedId");
      alert($(".test", dotted).length + " vs " + $(".test", undotted).length);
  <body id="body">
    <button type="text" onclick="test()">Press to test</button>
    <div id="Dotted.Id" style="border: 2px solid red">
      <p class="test">Test</p>
    <div id="UndottedId" style="border: 2px solid black">
      <p class="test">Test</p>

When you press the button the "alert" displays "0 vs 1", stating it find 0 elements with class "test" inside "Dotted.Id" but one inside "UndottedId".

If you include "jquery-1.4.2-min.js" instead, it displays "1 vs 1", stating that it finds one result in each DIV, no matter its Id.

Change History (2)

comment:1 Changed 9 years ago by jitter

Component: unfiledselector
Milestone: 1.next1.5
Priority: undecidedhigh
Resolution: duplicate
Status: newclosed

Thanks for taking the time to contribute to the jQuery project by writing a bug report and providing a test case!

This is a known issue and already fixed in the jQuery 1.5b1 release. This test case shows that it now works as expected again.

Check the ticket mentioned below for more information.

Also the next time please consider first searching the bug tracker if your issue hasn't already been filed, because there are like 15+ duplicates of this one already on the bug tracker.

comment:2 Changed 9 years ago by jitter

Duplicate of #7533.

Note: See TracTickets for help on using tickets.