Side navigation
#8021 closed bug (duplicate)
Opened January 20, 2011 09:29AM UTC
Closed January 20, 2011 02:42PM UTC
Last modified January 20, 2011 02:42PM UTC
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: |
Description
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:
<html> <head> <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); } </script> </head> <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> <div id="UndottedId" style="border: 2px solid black"> <p class="test">Test</p> </div> </body> </html>
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.
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.