<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>insomnia bytes &#187; Web</title>
	<atom:link href="http://bytes.inso.cc/wp/category/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://bytes.inso.cc/wp</link>
	<description>Imagination is a nightbird's dream</description>
	<lastBuildDate>Sat, 07 Nov 2009 17:13:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Internet Explorer strips leading whitespaces in text nodes</title>
		<link>http://bytes.inso.cc/wp/2009/11/07/internet-explorer-strips-leading-whitespaces-in-text-nodes/</link>
		<comments>http://bytes.inso.cc/wp/2009/11/07/internet-explorer-strips-leading-whitespaces-in-text-nodes/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 17:13:07 +0000</pubDate>
		<dc:creator>theefer</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[internet.explorer]]></category>

		<guid isPermaLink="false">http://bytes.inso.cc/wp/?p=938</guid>
		<description><![CDATA[For some mysterious reason, Internet Explorer (tested in IE7 and IE8) strips leading spaces in text nodes preceded by an empty element, such as this:
[code lang="html"]
 foo
[/code]
While innoccuous in static pages, it becomes problematic when DOM nodes get updated after a delay by some Javascript, as the separating whitespace has disappeared, hence ruining the layout [...]]]></description>
			<content:encoded><![CDATA[<p>For some mysterious reason, Internet Explorer (tested in IE7 and IE8) strips leading spaces in text nodes preceded by an empty element, such as this:</p>
<p>[code lang="html"]
<div><span></span> foo</div>
<p>[/code]</p>
<p>While innoccuous in static pages, it becomes problematic when DOM nodes get updated after a delay by some Javascript, as the separating whitespace has disappeared, hence ruining the layout of your text.</p>
<p>Surprisingly, I haven&#8217;t found any reference to this IE bug (not that there is a shortage of complaints about other IE idiosyncrasies), so I thought I&#8217;d share the problem and the solution I have found here. It&#8217;s all demonstrated in the following example:</p>
<p>[code lang="html"]<br />
< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><br />
<html><br />
<head></p>
<p>  <script type="text/javascript">
    function fill(name) {
      var e = document.getElementById(name);
      e.innerHTML = 'hello';
    }
  </script><br />
</head><br />
<body onload="fill('hello1'); fill('hello2');"></p>
<h1><span id="hello1"></span> world</h1>
<h1><span id="hello2">&nbsp;</span> world</h1>
<p></body><br />
</html><br />
[/code]</p>
<p>In the first case, the whitespace gets stripped, thus resulting in “Helloworld”. In the second example, the non-breaking space prevents IE from stripping the whitespace, so that when the span is filled by Javascript, the text reads “Hello world” as expected.</p>
<p>If you know other solutions or whether it&#8217;s considered a bug that will be fixed, please post in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://bytes.inso.cc/wp/2009/11/07/internet-explorer-strips-leading-whitespaces-in-text-nodes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
