Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#895 closed bug (fixed)

js error when selecting a non unexisting id (description below)

Reported by: [email protected] Owned by:
Priority: critical Milestone: 1.1.3
Component: core Version: 1.1.1
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by joern)

I'm using jQuery-1.1.1.js.

I have the following js code:

$("#componentId #menuId").bind("click", function(e) {			
     //do something useful.

and this markup:

<div id="componentId">
  <div id="menuId">Text</div>

This works ok... but, suppose that the generated markup will not contain a div with "componentId" ID, as below:

<div id="anotherComponentId">
  <div id="menuId">Text</div>

... then the script will throw an error at the line 954 :

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

I know that this issue can be avoided by changing my query code to:

$("#componentId").find("#menuId").bind("click", function(e) {			
     //do something useful.

instead of

$("#componentId #menuId").bind("click", function(e) {				
     //do something useful.

... still I think this is a bug which could be fixed. What do you think?

Thank you! Regards, Alex.

PS: I enjoy jQuery very much, it is a wonderful library. Keep doing a great job!

Change History (5)

comment:1 Changed 16 years ago by joern

Description: modified (diff)

comment:2 Changed 16 years ago by joern

Resolution: worksforme
Status: newclosed

According to tests this works in the latest revision of jQuery.

comment:3 Changed 16 years ago by jgrucza

Resolution: worksforme
Status: closedreopened

This is still not working in 1.1.2. Please fix.

comment:4 Changed 16 years ago by jgrucza

(Since your bug tracker doesn't seem to show duplicate bugs, also see http://dev.jquery.com/ticket/881)

comment:5 Changed 16 years ago by john

Milestone: 1.1.3
Resolution: fixed
Status: reopenedclosed
Version: 1.1.1

Fixed in SVN rev [1573].

Note: See TracTickets for help on using tickets.