[whatwg] document.head

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.


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