Bug Tracker

Ticket #895 (closed bug: fixed)

Opened 2 years ago

Last modified 1 year ago

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

Reported by: alexandru.objelean@… Assigned to: anonymous
Type: bug Priority: critical
Milestone: 1.1.3 Component: core
Version: 1.1.1 Keywords:
Cc: Needs:

Description (last modified by joern) (diff)

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>
</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>
</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!

Attachments

Change History

Changed 2 years ago by joern

  • description changed from 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> </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> </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! to 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> </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> </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!

Changed 2 years ago by joern

  • status changed from new to closed
  • resolution set to worksforme

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

Changed 2 years ago by jgrucza

  • status changed from closed to reopened
  • resolution deleted

This is still not working in 1.1.2. Please fix.

Changed 2 years ago by jgrucza

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

Changed 2 years ago by john

  • status changed from reopened to closed
  • version set to 1.1.1
  • resolution set to fixed
  • milestone set to 1.1.3

Fixed in SVN rev [1573].

Note: See TracTickets for help on using tickets.