2006-10-17 21:43 UTC The DOM0 Legacy: document.title
I'm trying to specify document.title. Here's
a list of quirks and outright bugs that I have found so far:
- IE7
-
titleelements created by the parser don't have child nodes, but you can see their value in theinnerHTMLserialisation. (DOM-createdtitleelements do have child nodes, however.)- Adding a
titleelement via the DOM has no effect ondocument.title.- The first
titleelement that is parsed by the parser is associated withdocument.title. If there is already such a node, then the new one is ignored by the parser.- Changing
document.titlechanges the innerHTML of the associatedtitleelement, potentially creating one at the start of theheadelement if required.- Trying to append a child text node to the magic
titleelement results in an exception being raised: "Unexpected call to method or property access".- Trying to change the magic
titleelement'sinnerHTMLgives an "Unknown runtime error". - Adding a
- Firefox trunk
-
Setting
document.titledoesn't affect the DOM, and is sticky; further changes to the DOM no longer affectdocument.title.- The first
titleelement that the parser sees sets thedocument.titlevalue to the element'stextContent. - The first
- Safari trunk
-
If a
titleelement is inserted into the DOM, it is associated withdocument.title, unless another node is already associated with it.- If the associated
titleelement is removed from the document, it loses its association.- Setting
document.titledirectly doesn't affect the DOM but sets an override that causes further accesses of that attribute to return the set value, until the set value is forgotten.- Appending things to the associated
titleelement works per the DOM, and causes any override setting of thedocument.titleto be forgotten.- Setting a
titleelement'sinnerHTMLattribute rasises aNO_MODIFICATION_ALLOWED_ERRexception.- Getting
document.titlereturns the concatenation of all the text node children of the associatedtitleelement, unless an override is in effect, in which case that is returned instead. - If the associated
- Opera9
-
In the parser, a
titlestart tag doesn't imply aheadstart tag, nor dotitletags in the body end up as elements in thehead.- Parsed
titleelements always have a text node child, even when that node is empty.- Setting
document.titlewhen there's notitleelement in the DOM does nothing, otherwise it deletes all the child nodes of the firsttitleelement in the DOM and then (if it wasn't set to the empty string) appends a single text node containing the new value.- Getting
document.titlereturns the text of the first node (if it's a text node) of the firsttitleelement in the document (if there is one).- You can append a
titleelement (or indeed any element) to theDocumentnode, such that the document has more than one root node. - Parsed