[whatwg] Handling <title> inside <body>

Tommy Thorsen tommy at kvaleberg.com
Tue Nov 11 02:58:02 PST 2008


Ian Hickson wrote:
> On Mon, 10 Nov 2008, Tommy Thorsen wrote:
>> From an implementors point of view, it's good to have clearly defined 
>> boundaries between modules. An implementation would typically have one 
>> module that tokenises and parses html and one module that renders the 
>> resulting dom to the screen. If all the unexpected input is dealt with 
>> in the parsing module, then you can make some assumptions in the 
>> rendering module which can greatly simplify the implementation. Having 
>> to deal with an arbitrary amount of illegal input in either module is, 
>> IMHO, not the ideal design.
>>     
>
> Unfortunately, we have little choice in the matter. Scripting and XML both 
> allow you to unambiguously create highly non-conforming DOMs, e.g. with 
> <title> elements as the root element and <html> elements as children of 
> <input> elements. The renderer has to deal with all such DOMs.
>
>   

I just came across another related problem. Consider the following markup:

<!doctype html><select><title>TITLE</title></select>

My version of Firefox moves the title to head, Opera ignores the title 
completely, and the html 5 parsing algorithm produces the following 
peculiar markup:

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <select>TITLE</select>
    </body>
</html>

Should this title be allowed or ignored? Right now we ignore the start 
and end tags, but insert the CDATA into the select element. I'm tempted 
to ignore CDATA unless the current node is an option element in the "in 
select" insertion mode.


Since we were discussing scripts creating unexpected DOMs, I had to try 
the following:

<!doctype html>
<script>
    function button_onclick() {
        document.getElementById('myselect').innerHTML = 
'<title>TITLE</title>';
        alert('title inserted');
    }
</script>
<select id="myselect"></select>
<input type="button" value="Make Title" onclick="button_onclick();" />

On Firefox, the title is inserted into the select element, but does not 
actually work. Opera seems to prevent the title element from being 
inserted into the select element altogether.

-Tommy



More information about the whatwg mailing list