Closed
Bug 118327
Opened 23 years ago
Closed 23 years ago
appendChild() throws exception
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
VERIFIED
INVALID
People
(Reporter: golam, Assigned: jst)
References
Details
Attachments
(1 file)
287 bytes,
text/plain
|
Details |
From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.7+) Gecko/20020102 BuildID: 2002010203 It seems like appendChild method doesn't working at all. I've check example from http://mozilla.org/docs/dom/domref/dom_el_ref32.html#1018978 - it throws exception too. See testcase for more details. Error: uncaught exception: [Exception... "Node cannot be inserted at the specified point in the hierarchy" code: "3" nsresult: "0x80530003 (NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)" location: "file:///H:/tests/mbugs/bug6.html Line: 6"] Reproducible: Always Steps to Reproduce: 1. open testcase 2. open JS console Actual Results: exception Expected Results: appended element
Reporter | ||
Comment 1•23 years ago
|
||
Comment 2•23 years ago
|
||
Here's why: Per the DOM spec (http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html $1.1.1) a document can only have one element child. In your example, your document already has a <body> child, and you're adding another div child. So we throw an exception. Similarly, the dom reference example will work only when the document has no child element yet. I will add a comment in bug 93108 about it. Thanks for finding this problem! The correct way to add an element as child of the body tag, is to do document.body.appendChild(..) Marking the bug invalid.
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
Resolution: --- → INVALID
Comment 4•18 years ago
|
||
*** Bug 344333 has been marked as a duplicate of this bug. ***
Comment 5•18 years ago
|
||
*** Bug 293238 has been marked as a duplicate of this bug. ***
Component: DOM: Core → DOM: Core & HTML
QA Contact: stummala → general
You need to log in
before you can comment on or make changes to this bug.
Description
•