Closed Bug 501846 Opened 15 years ago Closed 15 years ago

document.getElementBy fails to find the object after a document.write

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: fabrizio_blanco, Unassigned)

References

Details

(Keywords: testcase, Whiteboard: [fixed by the HTML5 parser])

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 here is the code snippet that shows the problem: <script> document.write("<iframe id='xyz' name='xyz' width=728 height=90> </iframe>"); alert(document.getElementById('xyz')); </script> it will return null instead of the iframe object. This happens only on firefox 3.5 Reproducible: Always Steps to Reproduce: <script> document.write("<iframe id='xyz' name='xyz' width=728 height=90> </iframe>"); alert(document.getElementById('xyz')); </script> Actual Results: null Expected Results: Object
This seems Firefox-only but is not a regression.
Component: General → DOM: Core & HTML
Product: Firefox → Core
QA Contact: general → general
Attached file Reporter's testcase (deleted) —
Workaround: add <body> before <script> Similar to bug 178258 but doesn't seem to get fixed by my patch there...
Severity: critical → normal
Keywords: testcase
OS: Windows XP → All
Hardware: x86 → All
Adding body inside the document write seems to make it work as well: <script> document.write("<body><iframe id='xyz' name='xyz' width=728 height=90> </iframe></body>"); alert(document.getElementById('xyz')); </script>
Looks like a variant of the "scripts are hoisted to head" thin. Henri, is this an issue with the html5 parser? If not, can you please add a dep on that bug here, and maybe add a "todo" mochitest to the tree immediately, so we remember to enable it when we flip the pref?
Not an issue with the HTML5 parser.
Depends on: html5-parsing
Flags: in-testsuite?
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Whiteboard: [fixed by the HTML5 parser]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: