ezmiller wrote:
Now that seems like a plausible explanation, but the thing is that as I
understand it, every node should conform to the Node interface, and the
nodeInterface specifiies a appendChild function as well as a
removeChild function....
Just for clarification, the interface implementation tree we are talking
about is
Node (W3C DOM Level 2 Core)
|
'- Element (W3C DOM Level 2 Core)
|
'- HTMLElement (W3C DOM Level 2 HTML)
|
'- HTMLTitleElement (W3C DOM Level 2 HTML)
So you are right that HTMLTitleElement objects (i.e. objects implementing
that interface) should have an appendChild() method, and indeed they have
here (Firefox/1.0.7 on GNU/Linux).
However, that `title' element represented can have only and must have one
child text node, and that text node is already there, even if empty. Try
alert(document.getElementsByTagName("title")[0].childNodes.length);
in a Valid HTML 4.01 document with <title></title>. Should yield 1, and
if you try
alert(document.getElementsByTagName("title")[0].childNodes[0].nodeType);
it should yield 3 which equals the value of Node::TEXT_NODE.
Removing it would invalidate the underlying markup.
<URL:http://www.w3.org/TR/html4/struct/global.html#edef-TITLE>
Note that the #PCDATA content may be empty, but is AIUI _not_ optional.
Therefore the specified shortcut HTMLDocument::title, implemented as
document.title, exists to read and modify the value of that text node.
JFTR: In my UA,
document.getElementsByTagName("title")[0].nodeValue = "blurb";
does work (`nodeValue' value is changed, no error or exception), but does
not change the title of the window/tab. document.title="blurb" changes the
title of the window/tab, but does not change the nodeValue. I assume this
peculiarity is due to history when document.title was already part of DOM
Level 0.
PointedEars