Subj : Re: appendChild() with e4x
To : netscape.public.mozilla.jseng
From : Martin Honnen
Date : Thu Aug 25 2005 05:41 pm
Marco Mariani wrote:
> I'm using Deer Park alpha 2, and trying E4X for the first time.
> foo = document.getElementById('foo'); // an empty
element
> foo.innerHTML =
Text
; // works
What do you mean by "works"? I think Mozilla does not give you an error
on that assigment but I don't think it makes much sense to attempt that.
On the right hand side you have a native XML object, on the left side
you try to assign to the innerHTML of a DOM element where innerHTML is
supposed to be set to a string with markup.
I think what Mozilla and IE do if you try to set innerHTML of a DOM
element to an object is that they call the toString method of the object
and parse the result as a HTML snippet.
So in the above case the toString method of that native XML object is
called which yields 'Text' and that is then parsed as a HTML snippet and
inserted into the foo element as its content meaning after that
assignment the foo element has one text child node with the content 'Text'.
Is that what you want to achieve?
> foo.appendChild(
Text
); // doesn't work
> Firefox replies with
>
> Error: [Exception... "Node cannot be inserted at the specified point in
> the hierarchy"
> code: "3" nsresult: "0x80530003 (NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)"
>
>
> Is this due to missing wrappers between DOM and E4X ?
As far as I know no such wrappers are implemented so far but even with
the wrappers my understanding of the suggested approach in the E4X
specification is that you need to call the domNode method on an XML
object to get a DOM node e.g. if you really wanted to do the above then
foo.appendChild(
.domNode())
would be the way suggested in the E4X specification.
Here is the E4X<-->DOM integration bug:
Nothing has happened there for quite a while so I am not sure whether
there is any intention at all to have that integration available in
Firefox 1.5.
--
Martin Honnen
http://JavaScript.FAQTs.com/
.