Skip to main content

Bug Tracker

Side navigation

#986 closed bug (fixed)

Opened February 21, 2007 08:02AM UTC

Closed March 24, 2007 02:54AM UTC

Last modified June 21, 2007 02:38AM UTC

jQuery("#IDParent #IDChild") throws error when #IDParent does not exists.

Reported by: alexo Owned by:
Priority: major Milestone: 1.1.3
Component: core Version: 1.1.1
Keywords: id selector error Cc:
Blocked by: Blocking:

This bug was reproduced using "jQuery-1.1.1" version.

I have the following code.

		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>Untitled Document</title>
		<script type="text/javascript" src="lib/jquery/jquery-1.1.1.js"></script>
    		jQuery(document).ready(function() {
                jQuery("#IDParent #IDChild").css("background", "red");                                			
          <div id="IDParent">
            <div id="IDChild" class="menuClass">Text</div>

If instead of

          <div id="IDParent">...</div>  

you change the ID to something else (different from id used in the query), for instance:

          <div id="AnotherIDParent">...</div>  

the same query throws the following error at line 954.

 if ( m[1] == "#" && ret[ret.length-1].getElementById ) {

I know that the above query could be fixed this way:

  jQuery("#IDParent").find(#IDChild").css("background", "red"); 

still, it would be nice if the original code would work the same way.

Thank you!


Attachments (0)
Change History (3)

Changed February 22, 2007 06:00PM UTC by aercolino comment:1

''the above query could be fixed this way''


''the above query could be made fail quietly this way''

Changed February 22, 2007 09:55PM UTC by john comment:2

milestone: → 1.1.2
priority: minormajor

Added a test case for this in rev [1405].

Changed March 24, 2007 02:54AM UTC by john comment:3

resolution: → fixed
status: newclosed

Fixed in SVN rev [1573].