Closed Bug 323745 Opened 19 years ago Closed 19 years ago

DOM replaceChild() function is broken for top-level elements

Categories

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

1.8 Branch
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 297801

People

(Reporter: porton, Unassigned)

Details

(Keywords: regression)

User-Agent:       Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.8) Gecko/20051118 Debian/1.4.99+1.5rc3.dfsg-1 Firefox/1.5
Build Identifier: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.8) Gecko/20051118 Debian/1.4.99+1.5rc3.dfsg-1 Firefox/1.5

The following XHTML file shows nothing instead of showing "Para" paragraph as it should.

The bug is that .replaceChild() function in this context does not work as expected.

I have quickly reviewed the DOM2 standard and concluded that it should work accordingly the standard. In any case it should work in our browser.

Note that the bug appears in both case if the below file is saved as .html or as .xml (XHTML).

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Test</title>
    <script type="text/javascript">
      function on_load() {
        document.replaceChild(document.documentElement.cloneNode(true), document.documentElement);
      }
    </script>
  </head>
  <body onload="on_load()">
    <p>Para</p>
  </body>
</html>

Reproducible: Always

Steps to Reproduce:
1. Save the above file either as .html or .xml
2. Open the file with the browser.
Actual Results:  
Empty content area.

Expected Results:  
"Para" paragraph in the content area.

So I know no any good method to replace the loaded a HTML or XML document with an other DOM document.
About your testcase: I see the word Para in 1.0.7 and in trunk but not in the 1.5 release and in branch. 
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060116 Firefox/1.6a1 ID:2006011623
So this is a 1.8 branch regression, I tested with a 1.8 branch nightly and recent trunk build, the text is not visible only in a branch build. The node is there, according to DOM inspector, but it's not rendered.
Assignee: nobody → general
Status: UNCONFIRMED → NEW
Component: General → DOM
Ever confirmed: true
Keywords: regression
OS: Linux → All
Product: Firefox → Core
QA Contact: general → ian
Hardware: PC → All
Version: unspecified → 1.8 Branch
So this particular testcase "broke" when we started actually following the DOM spec for manipulation of document child lists (bug 278472).  On trunk, this was fixed by the fix for bug 297801.

So this is basically a duplicate of bug 297801; marking so.

Note that bug 297801 was filed about three months before the fix for bug 278472 was checked in, so things were quite nicely broken even without the help of bug 278472; all that changed is behavior on this specific testcase.

If someone wants to figure out how this testcase (which used to work somehow) differs from the one in bug 297801 (which didn't work), that would be nice too.

*** This bug has been marked as a duplicate of 297801 ***
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.