<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Adventures With document.documentElement.firstChild</title>
	<atom:link href="http://robert.accettura.com/blog/2009/12/12/adventures-with-document-documentelement-firstchild/feed/" rel="self" type="application/rss+xml" />
	<link>http://robert.accettura.com/blog/2009/12/12/adventures-with-document-documentelement-firstchild/</link>
	<description>Robert Accettura&#039;s Personal Blog on Web Development and Tech</description>
	<lastBuildDate>Fri, 10 Feb 2012 09:17:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Performance Calendar &#187; The art and craft of the async snippet</title>
		<link>http://robert.accettura.com/blog/2009/12/12/adventures-with-document-documentelement-firstchild/comment-page-1/#comment-1562046</link>
		<dc:creator>Performance Calendar &#187; The art and craft of the async snippet</dc:creator>
		<pubDate>Mon, 05 Dec 2011 10:16:53 +0000</pubDate>
		<guid isPermaLink="false">http://robert.accettura.com/?p=3169#comment-1562046</guid>
		<description>[...] document.documentElement is the HTML element and its first child must be the head. Not necessarily, as it turns out. If there&#8217;s a comment following the HTML element, WebKits will give you the comment as the first child. Here&#8217;s an investigation with a test case. [...]</description>
		<content:encoded><![CDATA[<p>[...] document.documentElement is the HTML element and its first child must be the head. Not necessarily, as it turns out. If there&#8217;s a comment following the HTML element, WebKits will give you the comment as the first child. Here&#8217;s an investigation with a test case. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://robert.accettura.com/blog/2009/12/12/adventures-with-document-documentelement-firstchild/comment-page-1/#comment-842195</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Sat, 26 Dec 2009 23:44:25 +0000</pubDate>
		<guid isPermaLink="false">http://robert.accettura.com/?p=3169#comment-842195</guid>
		<description>@James: Thanks, that&#039;s an old bug I totally forgot about.  It&#039;s now fixed so next time it should show correctly.</description>
		<content:encoded><![CDATA[<p>@James: Thanks, that&#8217;s an old bug I totally forgot about.  It&#8217;s now fixed so next time it should show correctly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://robert.accettura.com/blog/2009/12/12/adventures-with-document-documentelement-firstchild/comment-page-1/#comment-836779</link>
		<dc:creator>James</dc:creator>
		<pubDate>Mon, 14 Dec 2009 16:06:38 +0000</pubDate>
		<guid isPermaLink="false">http://robert.accettura.com/?p=3169#comment-836779</guid>
		<description>This post is a bit confusing on planet mozilla, as the HTML is partly parsed instead of displayed, so the comment is missing.</description>
		<content:encoded><![CDATA[<p>This post is a bit confusing on planet mozilla, as the HTML is partly parsed instead of displayed, so the comment is missing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ms2ger</title>
		<link>http://robert.accettura.com/blog/2009/12/12/adventures-with-document-documentelement-firstchild/comment-page-1/#comment-836151</link>
		<dc:creator>Ms2ger</dc:creator>
		<pubDate>Sun, 13 Dec 2009 14:02:35 +0000</pubDate>
		<guid isPermaLink="false">http://robert.accettura.com/?p=3169#comment-836151</guid>
		<description>According to HTML5, you should get the comment. (Relevant part of the spec: &lt;a href=&quot;http://www.whatwg.org/html5/#the-before-head-insertion-mode&quot; rel=&quot;nofollow&quot;&gt;&lt;cite&gt;The &quot;before head&quot; insertion mode&lt;/cite&gt;&lt;/a&gt;.) Mozilla&#039;s HTML5 parser matches the spec here.</description>
		<content:encoded><![CDATA[<p>According to HTML5, you should get the comment. (Relevant part of the spec: <a href="http://www.whatwg.org/html5/#the-before-head-insertion-mode" rel="nofollow"><cite>The &#8220;before head&#8221; insertion mode</cite></a>.) Mozilla&#8217;s HTML5 parser matches the spec here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://robert.accettura.com/blog/2009/12/12/adventures-with-document-documentelement-firstchild/comment-page-1/#comment-835936</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Sun, 13 Dec 2009 01:08:05 +0000</pubDate>
		<guid isPermaLink="false">http://robert.accettura.com/?p=3169#comment-835936</guid>
		<description>@Sean Hogan: Virtually all js libraries make it easy too for example $(&quot;head&quot;) will work in jQuery.</description>
		<content:encoded><![CDATA[<p>@Sean Hogan: Virtually all js libraries make it easy too for example $(&#8220;head&#8221;) will work in jQuery.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Hogan</title>
		<link>http://robert.accettura.com/blog/2009/12/12/adventures-with-document-documentelement-firstchild/comment-page-1/#comment-835927</link>
		<dc:creator>Sean Hogan</dc:creator>
		<pubDate>Sun, 13 Dec 2009 00:05:45 +0000</pubDate>
		<guid isPermaLink="false">http://robert.accettura.com/?p=3169#comment-835927</guid>
		<description>If you need to access document.head more than once it is probably worth adding it (if it doesn&#039;t already exist):

if (!document.head) document.head = document.getElementsByTagName(&quot;head&quot;)[0];

This should always work in HTML pages, even if the script occurs before the  tag.</description>
		<content:encoded><![CDATA[<p>If you need to access document.head more than once it is probably worth adding it (if it doesn&#8217;t already exist):</p>
<p>if (!document.head) document.head = document.getElementsByTagName(&#8220;head&#8221;)[0];</p>
<p>This should always work in HTML pages, even if the script occurs before the  tag.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://robert.accettura.com/blog/2009/12/12/adventures-with-document-documentelement-firstchild/comment-page-1/#comment-835924</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Sat, 12 Dec 2009 22:59:32 +0000</pubDate>
		<guid isPermaLink="false">http://robert.accettura.com/?p=3169#comment-835924</guid>
		<description>@google analytics: The new code I think is pretty solid since it leaves little to chance.  I&#039;m pretty sure even I won&#039;t manage to break it, at least from the implementers standpoint.

@Boris: My expectations were admittedly based on previous experience more than specs.  Not sure if I&#039;ve ever run across a situation exactly like this before.

@Matt: I&#039;m aware of &lt;code&gt;document.head&lt;/code&gt;, though I don&#039;t foresee using that for quite some time when 99% of the world runs a web browser that will work on.  At the rate we&#039;re going that&#039;s 2029.</description>
		<content:encoded><![CDATA[<p>@google analytics: The new code I think is pretty solid since it leaves little to chance.  I&#8217;m pretty sure even I won&#8217;t manage to break it, at least from the implementers standpoint.</p>
<p>@Boris: My expectations were admittedly based on previous experience more than specs.  Not sure if I&#8217;ve ever run across a situation exactly like this before.</p>
<p>@Matt: I&#8217;m aware of <code>document.head</code>, though I don&#8217;t foresee using that for quite some time when 99% of the world runs a web browser that will work on.  At the rate we&#8217;re going that&#8217;s 2029.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://robert.accettura.com/blog/2009/12/12/adventures-with-document-documentelement-firstchild/comment-page-1/#comment-835915</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Sat, 12 Dec 2009 22:21:51 +0000</pubDate>
		<guid isPermaLink="false">http://robert.accettura.com/?p=3169#comment-835915</guid>
		<description>FYI document.head was added to HTML5[1] to simplify this case.  The issue you found was discussed[2] on the whatwg list as one of the reasons for a better way to access the head of the document.  Hopefully it will be one less browser compat. issue to worry about once implemented.

[1] http://www.whatwg.org/specs/web-apps/current-work/#dom-document-head
[2] http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-September/023105.html</description>
		<content:encoded><![CDATA[<p>FYI document.head was added to HTML5[1] to simplify this case.  The issue you found was discussed[2] on the whatwg list as one of the reasons for a better way to access the head of the document.  Hopefully it will be one less browser compat. issue to worry about once implemented.</p>
<p>[1] <a href="http://www.whatwg.org/specs/web-apps/current-work/#dom-document-head" rel="nofollow">http://www.whatwg.org/specs/we.....ument-head</a><br />
[2] <a href="http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-September/023105.html" rel="nofollow">http://lists.whatwg.org/htdig......23105.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Boris</title>
		<link>http://robert.accettura.com/blog/2009/12/12/adventures-with-document-documentelement-firstchild/comment-page-1/#comment-835914</link>
		<dc:creator>Boris</dc:creator>
		<pubDate>Sat, 12 Dec 2009 22:14:23 +0000</pubDate>
		<guid isPermaLink="false">http://robert.accettura.com/?p=3169#comment-835914</guid>
		<description>The DOM spec is the wrong place to look for this, since your question is really what the DOM should look like.  The relevant spec there would be the one that covers how to convert HTML source into a DOM: the HTML parsing spec.  There isn&#039;t one at the moment, though HTML5 is working on it.  So currently behavior is undefined. Not sure what the HTML5 draft proposes for the behavior.

In particular, whitespace before  is treated magically in various UAs and in the HTML5 draft last I checked; comments may or may not be depending.  It&#039;s interesting that you didn&#039;t expect firstChild to be the textnode coming before the comment; why not?</description>
		<content:encoded><![CDATA[<p>The DOM spec is the wrong place to look for this, since your question is really what the DOM should look like.  The relevant spec there would be the one that covers how to convert HTML source into a DOM: the HTML parsing spec.  There isn&#8217;t one at the moment, though HTML5 is working on it.  So currently behavior is undefined. Not sure what the HTML5 draft proposes for the behavior.</p>
<p>In particular, whitespace before  is treated magically in various UAs and in the HTML5 draft last I checked; comments may or may not be depending.  It&#8217;s interesting that you didn&#8217;t expect firstChild to be the textnode coming before the comment; why not?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: google analytics</title>
		<link>http://robert.accettura.com/blog/2009/12/12/adventures-with-document-documentelement-firstchild/comment-page-1/#comment-835912</link>
		<dc:creator>google analytics</dc:creator>
		<pubDate>Sat, 12 Dec 2009 21:54:55 +0000</pubDate>
		<guid isPermaLink="false">http://robert.accettura.com/?p=3169#comment-835912</guid>
		<description>Thanks for writing this!  Its good to get this documented.  We were aware of the issue...we just underestimated the number of sites with this with comments above the head.  We made the wrong tradeoff.  The new code isn&#039;t as terse, but it should cover pretty much any page you throw at it.</description>
		<content:encoded><![CDATA[<p>Thanks for writing this!  Its good to get this documented.  We were aware of the issue&#8230;we just underestimated the number of sites with this with comments above the head.  We made the wrong tradeoff.  The new code isn&#8217;t as terse, but it should cover pretty much any page you throw at it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

