Closed Bug 421153 Opened 16 years ago Closed 16 years ago

getElementById fails on pages containing only hidden input objects

Categories

(Firefox :: General, defect)

defect
Not set
minor

Tracking

()

RESOLVED DUPLICATE of bug 178258

People

(Reporter: grkaiser, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9b5pre) Gecko/2008030405 Minefield/3.0b5pre
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9b5pre) Gecko/2008030405 Minefield/3.0b5pre

If an HTML page contains only input objects that are marked as type="hidden" then getElementById will fail to find the object and return null. If the HTML page contains a mix of objects (hidden and non-hidden) then the hidden element can be found without a problem.

Example of page with only one object on it, a hidden input field. The javascript message will respond 'null':
http://soggybyte.com/software/ffx/jsoddity/testSingleHidden.html

Example of page with 2 objects, 1 hidden, 1 regular text. The javascript messages will respond with the HTML objects:
http://soggybyte.com/software/ffx/jsoddity/testWithOthers.html

The hidden-only page works in IE7, and Safari, but is broken in Firefox 2 and Firefox 3.

Please let me know if I can provide any more details, or if I can clarify what it is I'm babbling about. I apologize if this is a duplicate (I *did* search), or if this is an invalid bug. Thanks for your time guys and gals.

Reproducible: Always

Steps to Reproduce:
1. Create page with only hidden elements, and a small JS script to find and message that object.
2. Open in Firefox, and notice that the object is not found and we are told the object is null.
3. Create page with a mix of hidden and non-hidden elements, and a JS script to search for one of each type.
4. Open in Firefox, and notice that both types of objects are successfully found.
Actual Results:  
Firefox cannot find hidden elements if they are the only elements on the page.

Expected Results:  
Firefox can find hidden elements even if they are the only elements on the page.
Had the component marked as 'View Source' which I don't think is right. Changed to 'General'.
Component: View Source → General
Use <head> and <body> tags to avoid being bitten by bug 178258.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.