Opened 13 years ago

Closed 13 years ago

#7690 closed defect (fixed)

[patch][cla] bugfix to dojo.byId

Reported by: Mike Wilson Owned by: James Burke
Priority: high Milestone: 1.3
Component: HTML Version: 1.2beta
Keywords: Cc:
Blocked By: Blocking:


In the IE/Opera branch of dojo.byId there are a few bugs in these two lines:

  var eles = _d.all[id];
  if(!eles || !eles.length){ return eles; }

Bug 1: If only element is returned (no array and thus no .length property) it is assumed to be the match and is returned. Though, the matching element may have matched on its name property and then null should be returned instead.

Bug 2: Testing for an array or element return by inspecting .length is risky as some elements (f ex FORM) has length properties. It might be better to test on .tagName for elements instead.

I have just checked in similar improvements with test-cases in DWR's SVN if you want to take a look:

Change History (3)

comment:1 Changed 13 years ago by James Burke

Milestone: tbd1.3
Owner: changed from sjmiles to James Burke

I'm not sure Bug 1 is a bug? I wonder what the behavior is of document.getElementById() when there is an element with a name foo and a different element with id foo. I recall some weirdness with name/id collisions, but not the specifics.

I am a bit weak in this area, so I'll construct some tests. However, since we have had this code in the tree for over a year, I am going to wait for Dojo 1.3 to apply any fixes needed for the ticket.

comment:2 Changed 13 years ago by Mike Wilson

Hi jburke, Here's a free test case for Bug 1; it's really really simple :-)

<form name="thisIsMyName"></form>

If you run this on IE:


it will return the FORM instead of null.

All the best / Mike

comment:3 Changed 13 years ago by James Burke

Resolution: fixed
Status: newclosed

SVN integration not working, fixed in [16465].

Note: See TracTickets for help on using tickets.