Re: [whatwg] Document.title for SVG documents

On Tue, 4 Feb 2014, Cameron McCormack wrote:
> Ian Hickson wrote:
> > I'm all for handling it in one place. What precisely do you want the
> > behaviour to be? (Consider HTML-in-SVG and SVG-in-HTML also -- "the first
> > <svg:title>  element" may come after "the first<html:title>  element", and
> > vice versa. Also consider when one or the other is "primary" but the
> > relevant element is absent.)
> 
> OK, how about: if the document element is an <html:html>, we choose the 
> first <html:title> in document order; if the document element is an 
> <svg:svg>, we choose the first child <svg:title> of the document 
> element; otherwise, null.
> 
> This still is going to produce "incorrect" results for things like:
> 
>   <!DOCTYPE html>
>   <svg>
>     <foreignObject>
>       <title>blah</title>
>     </foreignObject>
>   </svg>
> 
> but arguably you shouldn't be using <title> in there anyway.

It doesn't seem useful to hit that element. It's not the (SVG) document 
title, after all.

I ended up going with:

 - if it's an SVG document, use the first <title> child of the root 
   element

 - if it's an HTML document, use the first <title> element in tree order
   (that's what it used to be)

For setting it uses the same element, unless there isn't one, in which 
case:

 - if it's an SVG document, append an SVG <title> to the root element

 - if it's an HTML document, append a <title> to the <head>

Hopefully that's compatible enough. Let me know if you need something 
different.


On Mon, 3 Feb 2014, Jonas Sicking wrote:
> 
> An even simpler solution would be to say "we choose the first 
> <html:title> or <svg:title> in document order". That has the nice 
> property that we align SVG and HTML more.

This seems to not quite match the SVG semantics, unfortunately.


On Wed, 5 Feb 2014, Simon Pieters wrote:
> 
> Is there a situation in which it is conforming to use html:title outside 
> the <head> in a document where the root is html:html? In 
> math:annotation-xml?

You can certainly imagine a compound document format containing entire 
HTML subdocuments, <html>, <head>, <title>, and all. I'm not sure that's 
possible with just SVG and HTML currently though. (Maybe MathML, indeed.)

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Tuesday, 1 April 2014 18:55:49 UTC