when using importNode, the class attribute is not taken into account

RESOLVED INVALID

Status

()

Core
DOM: Core & HTML
RESOLVED INVALID
14 years ago
10 years ago

People

(Reporter: Laurent Goujon, Unassigned)

Tracking

Trunk
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

14 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803 Epiphany/1.2.7
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803 Epiphany/1.2.7

When using document.importNode on elements from an XML Document (the problem
doesn't occur on an HTML document) to a HTML Document, the class attribute is
not taken into account, and so some stylesheets are not applied on this element
in the HTML Document

Reproducible: Always
Steps to Reproduce:
1. Write test.html

<html>
<head>
<style type="text/css">
        .test {background-color: red;}
</style>
<script type="text/javascript">
        w = open("test.xml", "test", null);
 
        function myImport() {
                var nodeToImport = w.document.getElementsByTagName("div")[0];
                var node = document.importNode(nodeToImport, true);
                document.getElementById("dest").appendChild(node);
        }
        window.onload = myImport;
</script>
 
</head>
<body>
        Imported node :
        <div id="dest"></div>
</body>
</html>

2. Write test.xml

<div id="toImport" class="test">
        Node to be imported !
</div>

3. Open test.html in Mozilla

Actual Results:  
In the main window, "Node to be imported" is inserted in the main window but the
background colors remains white;

Expected Results:  
"Node to be imported" should be printed with a red background-color (or
stylesheet must be applied on this node)

Perhaps it's related to bug #251025
This is correct behaviour. That <div> is not an HTML <div>, it's a <div> in the 
null namespace. If you want it to work, you have to make it an XHTML <div> by 
putting the xmlns="http://www.w3.org/1999/xhtml" attribute on the <div> in your 
test.xml file.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 14 years ago
Resolution: --- → INVALID

Updated

10 years ago
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.