Re: The future of XML related technologies in Mozilla
Boris Zbarsky <[email protected]> Wed, 01 Nov 2006 12:07:53 -0600
| Newsgroups | gmane.comp.mozilla.devel.xml |
|---|---|
| Message-ID | <[email protected]> |
Ian Hickson wrote:
>> I maintain that it still makes the simple use case of "serialize this node and
>> all its descendants" nontrivial. Compare:
...
>> var str = (new DOMSerializer()).serializeToString(node);
...
> No no, innerHTML would apply to everything, so the equivalent would be:
>
> var str = node.innerHTML;
OK, I sense a significant communications failure here. Let's say we have:
<div id="foo">Text</div>
and script as follows:
var node = document.getElementById("foo");
var str = (new DOMSerializer()).serializeToString(node);
var str2 = node.innerHTML.
Then str is the string: '<div id="foo">Text</div>'
while str2 is the string: 'Text'
To get the string in |str| using innerHTML, you would have to use the
code with importNode and company that I posted in my previous post.
This is why outerHTML exists, fwiw.
> (Currently the spec says it applies to HTMLElement only, but I'd be happy
> to put it on Element if you think there's a use case for that.)
There's absolutely a use case for that, imo.
-Boris