Opened 12 years ago

Closed 12 years ago

#11831 closed defect (fixed)

dojo.byId returns null or undefined depending on path

Reported by: miketaylr Owned by: anonymous
Priority: high Milestone: 1.6
Component: General Version: 1.5
Keywords: Cc: dante
Blocked By: Blocking:


The comments on lines 5282 and 5283, for dojo.byId say:

Returns DOM node with matching id attribute or null if not found. If id is a DomNode?, this function is a no-op.

From what I can tell, it returns undefined or null depending on the code path. The IE/Opera path returns undefined, while the getElementById path returns null, per spec.

There's some code on that breaks due to someone testing for null rather than truthiness

this.osectionFooterNonSub = dojo.byId("hrefSubId");

followed by:

if (this.osectionFooterNonSub !== null) {
    dojo.connect( this.osectionFooterNonSub, "onclick", this, function(ev) {
    window.location = this.osectionFooterNonSub.href;

Change History (2)

comment:1 Changed 12 years ago by James Burke

Milestone: tbd1.6

comment:2 Changed 12 years ago by James Burke

Resolution: fixed
Status: newclosed

(In [22972]) Fixes #11831 and #11832. Make sure byId consistently returns null, and use the standards path for Opera, confirmed that it works for what we support by an Opera person, and the change does not affect Core test results. \!strict

Note: See TracTickets for help on using tickets.