Opened 8 years ago

Closed 7 years ago

#14257 closed defect (fixed)

[patch] dojo.byId return undefined in IE

Reported by: vita Owned by: bill
Priority: high Milestone: 1.8
Component: HTML Version: 1.6.1
Keywords: byId undefined IE Cc:
Blocked By: Blocking:

Description

If dojo.byId cannot find DOMElement corresponding to its input, it return undefined instead of null. This bug is in IE only.

Attachments (2)

dojo1.6.1.html.diff (774 bytes) - added by vita 8 years ago.
dojo1.7.1.dom.diff (237 bytes) - added by vita 8 years ago.

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by vita

Attachment: dojo1.6.1.html.diff added

Changed 8 years ago by vita

Attachment: dojo1.7.1.dom.diff added

comment:1 Changed 8 years ago by bill

Component: CoreHTML
Milestone: 1.6.2tbd
Owner: set to Eugene Lazutkin
Summary: dojo.byId return undefined in IE[patch] dojo.byId return undefined in IE

Not sure if there's a CLA but patch is a one-liner so it shouldn't be needed. We do need a test though (or rather, to update the existing tests to catch this bug).

comment:2 Changed 8 years ago by Eugene Lazutkin

While the fix is trivial I prefer to update the documentation: "if id was not found, it returns a falsy value" meaning that you should test like that:

var node = dojo.byId(id);
if(node){
  // do something useful
}

Instead of:

if(node === null){
  // do something useful
}

comment:3 Changed 7 years ago by bill

Milestone: tbd1.8
Owner: changed from Eugene Lazutkin to bill
Status: newassigned

OK, I'll update the doc.

comment:4 Changed 7 years ago by bill

Resolution: fixed
Status: assignedclosed

In [29294]:

change doc of dom.byId() to indicate that it can return null or undefined, fixes #14257 !strict

Note: See TracTickets for help on using tickets.