Re: "The html element" (detailed review of the DOM)

On Wed, 25 Jul 2007, Simon Pieters wrote:
> 
> Some tests to figure out what IE does:
> 
>    http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0D%0A%3Cscript%3E%0D%0Avar%20e%20%3D%20document.createElement%28%22body%22%29%3B%0D%0Adocument.insertBefore%28e%2C%20document.documentElement%29%3B%0D%0Ae.appendChild%28document.createElement%28%22html%22%29%29%3B%0D%0Adocument.dir%3D%22ltr%22%3B%0D%0A%3C/script%3E
>    http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0D%0A%3Cscript%3E%0D%0Avar%20e%20%3D%20document.createElement%28%22foo%22%29%3B%0D%0Adocument.insertBefore%28e%2C%20document.documentElement%29%3B%0D%0Ae.appendChild%28document.createElement%28%22html%22%29%29%3B%0D%0Adocument.dir%3D%22ltr%22%3B%0D%0A%3C/script%3E
>    http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0D%0A%3Cscript%3E%0D%0Avar%20e%20%3D%20document.createElement%28%22body%22%29%3B%0D%0Adocument.insertBefore%28e%2C%20document.documentElement%29%3B%0D%0Avar%20ee%20%3D%20document.createElement%28%22bar%22%29%3B%0D%0Ae.appendChild%28ee%29%3B%0D%0Aee.appendChild%28document.createElement%28%22html%22%29%29%3B%0D%0Adocument.dir%3D%22ltr%22%3B%0D%0A%3C/script%3E

These all show a core DOM bug in IE, namely that it allows more than one 
element child of the Document.


> Now, I suggest that the definition of "the html element" be changed to 
> match what IE does, i.e.:
> 
>    The html element of a document is the first html element that doesn't
>    have a body or frameset element ancestor, if there is one, or null
>    otherwise.

I don't see any benefit to this -- it would only change the behaviour in 
non-compliant documents, and yet introduces some level of complexity to do 
so. The current text seems fine to me.

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

Received on Friday, 25 July 2008 22:55:40 UTC