document.body (detailed review of the DOM)

(This is part of my detailed review of the Document Object Model section.)

    http://simon.html5.org/test/html/dom/interfaces/HTMLDocument/body/

In IE and Opera, getting document.body returns the first body or frameset  
element in the document. In Firefox and Safari, it returns a body or  
frameset element that is child of the html root element. But it's not  
necessarily the first one. I haven't figured out what Firefox and Safari  
are doing exactly though.


In IE, document.body is readonly.

In Firefox, setting document.body raises an exception if the new value  
isn't a <body> or <frameset> element (like the spec says). However, if the  
existing document.body is a <frameset> element, the new value is appended  
to the root element.

In Safari, setting document.body raises an exception if the new value  
isn't an element. (Otherwise per spec.)

In Opera, setting document.body rasies an exception if the new value isn't  
a <body> element. If the existing document.body is a <frameset> element,  
the new value is appended to the root element.


I think the spec should be aligned with what IE and Opera do on getting,  
i.e. return the first body or frameset element in the document. I think  
the spec is fine for setting.

-- 
Simon Pieters
Opera Software

Received on Friday, 13 July 2007 12:14:10 UTC