Closed
Bug 275620
Opened 20 years ago
Closed 20 years ago
node.appendChild() is not displaying the imported nodes
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: chris, Unassigned)
References
()
Details
I have been playing with zool and firefox for a while and I think I have found a
bug in the implementation of the DOM. The attached url is a link to the post I
have put up on the XUL forums, but I think it might be deeper then that.
I have an element in a web page (XUL tree). I am trying to append child nodes
to the element through javascript using the following statments:
Code:
var tr = document.getElementById("tree-rows");
var stream = " <treeitem><treerow>";
stream += " <treecell label=\"1\"/>";
stream += " <treecell label=\"this is my name\"/>";
stream += " </treerow></treeitem>";
var doc = new DOMParser().parseFromString("<treechildren>" + stream +
"</treechildren>", 'text/xml');
doc=doc.firstChild;
tr.appendChild(tr.ownerDocument.importNode(doc,true));
//------------------------------------------------
// this way also works but doesn't render
//range = doc.createRange();
//range.selectNodeContents(doc.getElementsByTagName("treechildren")[0]);
//tr.appendChild(range.extractContents());
var items = document.getElementsByTagName("treeitem");
alert("Rows Loaded: " + items.length);
The really strange part is the elements appear in the DOM Inspector and can be
referenced in the document (as the alert shows). But the tree is not rendering
the rows.
Also if I use the DOM Inspector and click on the tree's rows, a red debug box
appears round the area I would expect to see the rendered nodes in.
The javascript console is not throwing any error's on running this code.
Comment 1•20 years ago
|
||
Not sure if this belongs to DOM or XP Toolkit/Widgets: XUL, but I'm sure it doesn't belong to Firefox : General.
Assignee: firefox → general
Component: General → DOM
Product: Firefox → Core
QA Contact: firefox.general → ian
Version: 1.0 Branch → Trunk
| Reporter | ||
Comment 2•20 years ago
|
||
I see the catagory has been changed for this, but has anyone picked it up? Do I need to do something else?
Comment 3•20 years ago
|
||
You have two bugs in your code:
1) You're appending a <treechildren> as a child of another <treechildren>.
2) When you parse, you're creating elements in the null namespace, not XUL
elements.
Fixing these bugs makes the treeitem show up, as one would expect.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
| Reporter | ||
Comment 4•20 years ago
|
||
Boris, Thanks for updating my case notes. Is there any chance you could possible post an example of your working code. I understand the whole "treechildren" one, but your second point I just don't get. I would really appricate it if you could help me out. Thanks
Comment 5•20 years ago
|
||
Make two changes: 1) Replace: doc=doc.firstChild; with: doc=doc.firstChild.firstChild.nextSibling; 2) Replace: var stream = " <treeitem><treerow>"; with: var stream = " <treeitem xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'><treerow>"; Or put the XUL namespace on the <treechildren> you parse. Or something. But at some point you have to tell the parser that you're creating XUL elements, and not, say, HTML.
| Reporter | ||
Comment 6•20 years ago
|
||
Thanks for your help.. I will add those changes to my app in the morning. It will make a huge performace difference in what I was doing...
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•