W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2009

[whatwg] document.head

From: Hallvord R M Steen <hallvors@gmail.com>
Date: Tue, 6 Oct 2009 15:02:58 +0100
Message-ID: <dd4c8a40910060702v77f71401ga1adc696b7cad549@mail.gmail.com>
2009/9/21 Garrett Smith <dhtmlkitchen at gmail.com>:

>> It wasn't very long ago though that in Opera for example, head wasn't
>> guaranteed to be the first child of the documentElement. But, that'll work
>> now and is pretty good.

> The documentElement.firstChild cannot be expected to be head. It could
> be a text node. For example:-
> <html>
> ? <head>
> ...
> the first child node of HTML looks like a textNode with the value
> "\n\n\u0020\u0020".

You might think so. However, as Michael stated above Opera used to do
this, and it broke a number of websites that expected
documentElement.firstChild to be <HEAD> no matter what the actual
markup looked like. So we had to implement a somewhat magic firstChild
on documentElement and I expect other browsers had to too (as your
testing seems to confirm, more or less). Which reminds me, this
peculiarity should possibly be documented in HTML5 :-) .
Hallvord R. M. Steen
Received on Tuesday, 6 October 2009 07:02:58 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:17 UTC