W3C home > Mailing lists > Public > public-html@w3.org > July 2007

Re: document.title (detailed review of the DOM)

From: Simon Pieters <simonp@opera.com>
Date: Wed, 25 Jul 2007 10:59:54 +0200
To: public-html <public-html@w3.org>
Message-ID: <op.tv0i940eidj3kv@hp-a0a83fcd39d2>

On Wed, 11 Jul 2007 12:06:20 +0200, Simon Pieters <simonp@opera.com> wrote:

> IE7:
>
> "A title element" is either created by the parser or by setting  
> document.title. There is always at least one "a title element". "A title  
> element" cannot have any child nodes, but its associated text is  
> available e.g. with the .text or .innerHTML attributes.
>
> On getting document.title, if there is "a title element" part of the  
> document that doesn't have a <body> element ancestor, then return the  
> first such element's associated text. Otherwise return the empty string.
>
> On setting document.title, if there is "a title element" part of the  
> document that doesn't have a <body> element ancestor, then associate the  
> new text with that element. Otherwise, create a new "a title element"  
> and associate the new text with it, and append it to the first <head>  
> element in the document that doesn't have a <body> element ancestor  
> (which fails if there isn't one).

s/<body>/<body> or <frameset>/ (appears 3 times).

    http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0D%0A%3Ctitle%3Ex%3C/title%3E%0D%0A%3Cscript%3E%0D%0Awindow.onload%20%3D%20function%28%29%20%7B%0D%0A%20%20document.body.appendChild%28document.getElementsByTagName%28%22title%22%29%5B0%5D%29%3B%0D%0A%20%20w%28document.title%29%3B%0D%0A%7D%0D%0A%3C/script%3E%0D%0A%3Cframeset%3E
    http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0D%0A%3Ctitle%3Ex%3C/title%3E%0D%0A%3Cscript%3E%0D%0Awindow.onload%20%3D%20function%28%29%20%7B%0D%0A%20%20document.body.appendChild%28document.getElementsByTagName%28%22title%22%29%5B0%5D%29%3B%0D%0A%20%20document.title%20%3D%20%22y%22%3B%0D%0A%7D%0D%0A%3C/script%3E%0D%0A%3Cframeset%3E
    http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0D%0A%3Ctitle%3Ex%3C/title%3E%0D%0A%3Cscript%3E%0D%0Awindow.onload%20%3D%20function%28%29%20%7B%0D%0A%20%20document.body.appendChild%28document.getElementsByTagName%28%22head%22%29%5B0%5D%29%3B%0D%0A%20%20document.title%20%3D%20%22y%22%3B%0D%0A%7D%0D%0A%3C/script%3E%0D%0A%3Cframeset%3E

> If we want to be more like IE, then I'd suggest the following spec text:
>
>     The head element of a document is the first head element that doesn't
>     have a body element ancestor.
>
>     The title element of a document is the first title element that  
> doesn't
>     have a body element ancestor.
>
>     The title attribute must, on getting, run the following algorithm:
>
>       1. If the root element is an svg element in the
>          "http://www.w3.org/2000/svg" namespace, and the user agent  
> supports
>          SVG, then the getter must return the value that would have been
>          returned by the DOM attribute of the same name on the  
> SVGDocument
>          interface.
>
>       2. Otherwise, it must return the .textContent of the title  
> element, or
>          the empty string if the title element is null.
>
>     On setting, the following algorithm must be run:
>
>       1. If the root element is an svg element in the
>          "http://www.w3.org/2000/svg" namespace, and the user agent  
> supports
>          SVG, then the setter must defer to the setter for the DOM  
> attribute
>          of the same name on the SVGDocument interface. Stop the  
> algorithm
>          here.
>
>       2. If the title element is null, then the following sub-algorithm  
> must
>          be run:
>
>            1. If the head element is null, then then the attribute must  
> do
>               nothing. Stop the overall algorithm here.
>
>            2. Otherwise, a new title element must be created and  
> appended to
>               the head element.
>
>       3. The children of the title element (if any) must all be removed.
>
>       4. A single Text node whose data is the new value being assigned  
> must
>          be appended to the title element.

s/body/body or frameset/ (appears 2 times).

-- 
Simon Pieters
Opera Software
Received on Wednesday, 25 July 2007 08:59:58 UTC

This archive was generated by hypermail 2.3.1 : Monday, 29 September 2014 09:38:47 UTC