- From: Geoffrey Sneddon <gsneddon@opera.com>
- Date: Thu, 16 Jul 2009 14:41:34 +0200
- To: public-html@w3.org
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. In all shipping browsers this creates: doctype html head body@bgcolor='red' This becomes more interesting once you add children to the body elements: <!doctype html> <script> document.documentElement.innerHTML = "<body bgcolor=green>PASS"; </script> <body bgcolor=red> <p>FAIL HTML 5: doctype html head body@bgcolor='green' "PASS" body@bgcolor='red' p "FAIL" Firefox/Chromium: doctype html "PASS" body@bgcolor='red' p "FAIL" Opera: doctype html head body@bgcolor='red' "PASS" p "FAIL" IE8 forbids setting innerHTML on the html element, so: doctype html head title "" script "document.documentElement.innerHTML = "<body bgcolor=green>PASS";" body@bgcolor='red' p "FAIL" 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. -- Geoffrey Sneddon — Opera Software <http://gsnedders.com/> <http://www.opera.com/>
Received on Thursday, 16 July 2009 12:42:15 UTC