Opened 14 years ago
Closed 14 years ago
#2982 closed defect (fixed)
[patch] [cla] dojo.byId fails (IE6,7 Opera) when used on a form, which has a element named/id'd "id"
Reported by: | Sam Foster | Owned by: | Douglas Hays |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | Core | Version: | 0.4.2 |
Keywords: | dojo.byId | Cc: | [email protected]…; [email protected]… |
Blocked By: | Blocking: |
Description (last modified by )
Problem is when you have a form with an element named "id", like:
<form id="foo"> <input name="id">
and then you do dojo.byId("foo")
the issue can be seen at http://www.sam-i-am.com/work/sandbox/dojo0.4/test_formsById.html
Note, document.getElementById does work here, whereas dojo.byId does not (in IE6,7,Opera)
This may be related to the issue in #2248 (where I've posted the same patch) The patch references ele.attributes.id, instead of ele.id inside the block that provides a workaround for IE/Opera bugs.
The patch has been tested to work/not regress (using the same page above) in IE6, 7, FF1.5, Safari, WebKit?, Opera 9.2
I'd love to get this in 0.4.3 if possible - we'll be on the 0.4 line for a while.
CLA on file as Sam Foster @ Vignette
Attachments (2)
Change History (8)
Changed 14 years ago by
Attachment: | hostenv_browser_byId_changes_sf.patch added |
---|
comment:1 Changed 14 years ago by
- Can you attach some example source code to demonstrate the problem? Moreover, the url that you provided results in a Page Not Found error.
- That "ele.attributes.id.value" in your patch should be "ele.getAttribute("id")". At least, what happens if "ele.attributes.id" is undefined? Can it be?
- I do not understand, how your patch fixes the problem. Why id="id" or name="id" is a problem? What line in hostenv_browser.js produces it and why?
Best regards,
Konstantin Kolinko
comment:2 Changed 14 years ago by
Reproduced the problem with dojo 0.9. The page to reproduce the problem is testCase_Form_HiddenFields.htm attached to ticket #2248.
Dojo version:
0.9, built from current development sources of revision 8529.
Browser:
IE6/Windows XP. Does not occur with IE7.
Steps to reproduce:
- Open "testCase_Form_HiddenFields.htm"
- An alert window shows up with the following message: "undefined"
Expected result:
- The message should be "[object]"
Please, disregard my "ele.getAttribute("id")" suggestion from above. It does not work with that test page in IE6. Evaluating
document.getElementById('myForm').getAttribute("id")
there returns the same as
document.getElementById('myForm').id
i.e. an object (a reference to the input field), not a string as were expected. The
document.getElementById('myForm').attributes.id.value
code though works, and returns a string, "myForm", not only in IE6, but also in IE7, Firefox 2.0.
Sorry for inconvenience.
Konstantin Kolinko
comment:3 Changed 14 years ago by
Owner: | changed from anonymous to Sam Foster |
---|
comment:4 Changed 14 years ago by
Description: | modified (diff) |
---|---|
Reporter: | changed from guest to Sam Foster |
comment:5 Changed 14 years ago by
Description: | modified (diff) |
---|---|
Milestone: | → 0.9 |
Owner: | changed from Sam Foster to Douglas Hays |
Summary: | dojo.byId fails (IE6,7 Opera) when used on a form, which has a element named/id'd "id" → [patch] [cla] dojo.byId fails (IE6,7 Opera) when used on a form, which has a element named/id'd "id" |
Doug, this is actually a patch to your code from [5739], so can you test/apply if appropriate?
comment:6 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Changed 14 years ago by
test case for the bug (where an element has name="id")
fixes dojo.byId to use ele.attributes.id instead of ele.id