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

Re: HTML 5 parser creating multiple body elements

From: Thomas Broyer <t.broyer@ltgt.net>
Date: Thu, 16 Jul 2009 16:03:26 +0200
Message-ID: <a9699fd20907160703j99ecb9bn18ff645159c9bd16@mail.gmail.com>
To: Geoffrey Sneddon <gsneddon@opera.com>
Cc: public-html@w3.org
On Thu, Jul 16, 2009 at 2:41 PM, Geoffrey Sneddon wrote:
> Given the following:
> <!doctype html>
> <script>
> document.documentElement.innerHTML = "<body bgcolor=green>";
> </script>
> <body bgcolor=red>
> The HTML 5 parser creates:
> doctype
> html
>        head
>        body@bgcolor='green'
>        body@bgcolor='red'
> It would be desirable not to create multiple body elements.
> None of these options seem very nice (HTML5 because it results in multiple
> body elements; Firefox/Chromium as they result in a text node child of the
> HTML element; Opera because it results in a P element child of the HTML
> element; IE because it disallows innerHTML). As IE throws when trying to set
> innerHTML on the HTML element (which, AFAIK, is the only case in which this
> can occur), I find it doubtful any sites depend on any specific behaviour,
> though it seems nicest to avoid having multiple body elements, and treating
> it closer to two body elements in the token stream.

How about changing step 2 in setting innerHTML to "If the node's
document has an active parser"? (instead of "If the attribute is being
set on a Document node, and that document has an active parser")
It wouldn't match any browser but as you said, given that IE throws,
it is "doubtful any sites depend on any specific behaviour".

I believe there are similar issues with insertAdjacentHTML, and
probably even after the parser has stopped (as soon as there is a
<body>, even when using outerHTML e.g. on <head>).

Thomas Broyer
Received on Thursday, 16 July 2009 14:04:05 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:48 UTC