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

[whatwg] document.head

From: Ian Hickson <ian@hixie.ch>
Date: Mon, 5 Oct 2009 23:28:28 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0910052318540.25383@hixie.dreamhostps.com>
On Sun, 20 Sep 2009, Joseph Pecoraro wrote:
>
> Was there any discussion for including "document.head" in HTML5?  
> Searching the mailing list shows document.head show up a few times in 
> example code [1][2].  However, there has been no proposal, and it is not 
> mentioned in the document's IDL [3] in the Spec.
> 
> Developers often do the following to get a reference to the <head> 
> element (top 2 google results) [4]:
> 
>     var head = document.getElementsByTagName('head')[0];
> 
> Its useful for developers to use that reference to manipulate/append 
> stylesheets, scripts, and <style> elements which are only valid inside 
> the <head> when the scope attribute is absent [5].
> 
> I feel this would be useful to add.  It is confusing that there is a 
> "document.body" but no "document.head".  If added, code that interacts 
> with the <head> would be much clearer then the current popular approach 
> (shown above).  Also, the current approach, barring optimizations in the 
> engine, could search the entire DOM tree.

Done.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Monday, 5 October 2009 16:28:28 UTC

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