Closed Bug 293387 Opened 20 years ago Closed 20 years ago

Wrong replaceChild() behavior on inline element with block inside

Categories

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

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: lorus, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.7) Gecko/20050420 Firefox/1.0.3
Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.7) Gecko/20050420 Firefox/1.0.3

When replaceChild() is used to replace an inline element (such as <span>) which
contains block element (such as <div>) inside, browser just duplicates contents
of <span> and displays it twice.
At the same time DOM Inspector doesn't show any duplicated nodes.

Reproducible: Always

Steps to Reproduce:
Here is a testcase.

<html>
<head>
<script language="JavaScript" type="text/javascript">
function reproduceBug(name) {
        var victim = document.getElementById(name);
        var replacement = victim.cloneNode(true);
        var parent = victim.parentNode;
        parent.replaceChild(replacement, victim);
}
</script>
</head>
<body>
<a href="javascript:void(0);" onclick="reproduceBug('victim');">reproduce bug
(block inside &lt;span&gt')</a>
<div>
        <span id="victim">
                <div>
                        text
                </div>
        </span>
</div>
<hr/>
<a href="javascript:void(0);" onclick="reproduceBug('solid');">not reproduceable
(block inside block)</a>
<div>
        <div id="solid">
                <div>
                        text
                </div>
        </div>
</div>
</body>
</html>
Actual Results:  
Clicking on the first link multiplies the 'text' word. Clicking on the second
link works as expected (nothing happens visually).

Expected Results:  
Inline element should be completely replaced with new node by replaceChild(),
not duplicated.
Attached file reporter's testcase
reporter's testcase
I see the problem with Firefox 1.0 and 1.0.3 (and suite build 1.7.7), but this
worksforme with trunk builds since 1.8a1

resolving WORKSFORME -- gecko 1.7 branch is only getting security fixes
reopen if you reproduce the bug with a trunk build.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → WORKSFORME
Component: DOM: Core → DOM: Core & HTML
QA Contact: ian → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: