<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>DOM Traversal</title><link>http://blogs.msdn.com/b/ie/archive/2010/07/30/dom-traversal.aspx</link><description>The latest Platform Preview Build includes two great interoperable features for working with the DOM &amp;ndash; DOM Traversal and Element Traversal . These features provide web developers with simple, flexible, and fast ways of traversing through a document</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: DOM Traversal</title><link>http://blogs.msdn.com/b/ie/archive/2010/07/30/dom-traversal.aspx#10048216</link><pubDate>Tue, 10 Aug 2010 06:19:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10048216</guid><dc:creator>wetran</dc:creator><description>&lt;p&gt;@Mitch 74,&lt;/p&gt;
&lt;p&gt;Your personal programming habits do NOT mean they should be obeyed by everyone.&lt;/p&gt;
&lt;p&gt;&amp;quot;one VAR statement is allowed by function or program body: don&amp;#39;t do &amp;#39;var i=something;var j=else;&amp;#39; but do &amp;#39;var i=something,j=else;&amp;#39;. Note that you can declare a variable without setting it, like this: &amp;#39;var i=something,j=else,x;&amp;#39;&lt;/p&gt;
&lt;p&gt;If declaring variables at the start of a function is so difficult, why do they do it in Delphi and in C (and all its descendants), I wonder. And while ECMAscript indeed allows multiple VAR statements, it&amp;#39;s good practice (and a performance saver) to allocate all your variables at the start: the parser and evaluator will not need to increase the &amp;quot;stack&amp;#39;s&amp;quot; size (or more probably, have to re-work the index) more than necessary.&amp;quot;&lt;/p&gt;
&lt;p&gt;Please, we are not in the 1980&amp;#39;s anymore. I&amp;#39;ve been programming since the early 1980&amp;#39;s, and yes in the early days performance and resource-saving WAS critical so people usually recommends those kind of &amp;quot;tricks&amp;quot;, but now we are in the 21st century, and currently we teach people program readability &amp;gt; performance and resource-saving, unless it&amp;#39;s some mission-critical low-level programming for stuffs like SoC and extremely limit resources. And one variable declaration for a whole program body is a big NO in this case. People prefer clearer and readable code much more than putting all kinds of important and temporary variables in one line at the start of a program. The performance gain of putting all variable declaration at the start in one line is negligible given today&amp;#39;s hardware resource and interpreter/compiler/JIT compiler optimization technologies. &lt;/p&gt;
&lt;p&gt;You can go look at any of those large websites and javascript frameworks out there, like Google&amp;#39;s web apps, Apple&amp;#39;s sites, Prototype framework, etc. etc. and you&amp;#39;ll find them using one VAR for one important variable declaration, for better code readability over negligible performance gains. For these couple decades, stuffs like &amp;quot;var i=something,j=else,x;&amp;quot; is the bad practice. Every program guide tells you to do &amp;quot;for (int i=0;i&amp;lt;something;i++) for (int j=0;j&amp;lt;else;j++) { ... }&amp;quot; nowadays, NOT &amp;quot;int a,b,c,i,j,k,...; &amp;nbsp;... after 100 lines of codes ... for (i=0;i&amp;lt;something;i++) for (j=0;j&amp;lt;else;j++) { ... }&amp;quot;, although the latter theoretically helps performance, it&amp;#39;s a big NO-NO in this day and age.&lt;/p&gt;
&lt;p&gt;Sames goes for the &amp;quot;!=&amp;quot; vs. &amp;quot;!==&amp;quot;, it&amp;#39;s like saying people should do &amp;quot;if (0==i)&amp;quot; instead of &amp;quot;if (i==0)&amp;quot;, that&amp;#39;s just some recommendations that theoretically improves productivity, but in reality it&amp;#39;s all down to personal preferences, the extra time costs to consciously typing the extra &amp;quot;=&amp;quot; everywhere when it&amp;#39;s not exactly needed, may far surpass the potential and theoretical productivity improvement.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10048216" width="1" height="1"&gt;</description></item><item><title>re: DOM Traversal</title><link>http://blogs.msdn.com/b/ie/archive/2010/07/30/dom-traversal.aspx#10045578</link><pubDate>Tue, 03 Aug 2010 20:47:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10045578</guid><dc:creator>anti-whiner</dc:creator><description>&lt;p&gt;Writing examples that are understandable is to be commended. And ALT is a supported attribute on OBJECT, AREA, APPLET and INPUT in addition to IMG.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10045578" width="1" height="1"&gt;</description></item><item><title>re: DOM Traversal</title><link>http://blogs.msdn.com/b/ie/archive/2010/07/30/dom-traversal.aspx#10045561</link><pubDate>Tue, 03 Aug 2010 20:24:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10045561</guid><dc:creator>ryan</dc:creator><description>&lt;p&gt;Why does MSFT always find odd examples to use?&lt;/p&gt;
&lt;p&gt;If you are testing for the alt attribute, then you are looking for images... those images are already available in a DOM-L0 collection; &lt;/p&gt;
&lt;p&gt;document.images&lt;/p&gt;
&lt;p&gt;thus you can save piles on the traversal with:&lt;/p&gt;
&lt;p&gt;for(var i=0,iL=document.images.length;i&amp;lt;iL;i++){&lt;/p&gt;
&lt;p&gt; &amp;nbsp;//do tests...&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;or even document.getElementsByTagName(&amp;#39;img&amp;#39;);&lt;/p&gt;
&lt;p&gt;You are surely not suggesting that developers should ignore the specs and add alt attributes to all kinds of other elements are you?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10045561" width="1" height="1"&gt;</description></item><item><title>re: DOM Traversal</title><link>http://blogs.msdn.com/b/ie/archive/2010/07/30/dom-traversal.aspx#10045388</link><pubDate>Tue, 03 Aug 2010 14:27:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10045388</guid><dc:creator>Dave</dc:creator><description>&lt;p&gt;&amp;gt; I’ve already found these features to be a great help in my own coding ...&lt;/p&gt;
&lt;p&gt;How so? Since a web site needs to deal with downlevel browsers, there will need to be a completely different code path for the two cases. That&amp;#39;s why we have frameworks like jQuery and Prototype trying to hide those differences. So I can see how frameworks might find these DOM traversal features useful, but if you&amp;#39;re using them bareback it seems like you&amp;#39;ll end up writing a lot of framework-like wrappers around them.&lt;/p&gt;
&lt;p&gt;Given that querySelectorAll exists, a NodeIterator or TreeWalker don&amp;#39;t seem that handy. I wouldn&amp;#39;t be surprised to find, for example, that document.querySelectorAll(&amp;quot;[alt*=space], [alt*=flight]&amp;quot;) is much faster than your example above, since there&amp;#39;s no Javascript involved in the node inspection or tree walk. &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10045388" width="1" height="1"&gt;</description></item><item><title>re: DOM Traversal</title><link>http://blogs.msdn.com/b/ie/archive/2010/07/30/dom-traversal.aspx#10045134</link><pubDate>Mon, 02 Aug 2010 21:17:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10045134</guid><dc:creator>BrianMB</dc:creator><description>&lt;p&gt;- CSS Transitions&lt;/p&gt;
&lt;p&gt;- CSS 2D Transforms&lt;/p&gt;
&lt;p&gt;- CSS Border Image&lt;/p&gt;
&lt;p&gt;Begging on both knees, IE Team. &amp;nbsp;Please make it happen!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10045134" width="1" height="1"&gt;</description></item><item><title>re: DOM Traversal</title><link>http://blogs.msdn.com/b/ie/archive/2010/07/30/dom-traversal.aspx#10045104</link><pubDate>Mon, 02 Aug 2010 20:23:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10045104</guid><dc:creator>greenunicorns</dc:creator><description>&lt;p&gt;Huh? Oh, was he accusing me of that? I assumed that he was just adamantly declaring that HE did not live in his mother&amp;#39;s basement. I completely missed that. Either way, where I live is irrelevant, and my credibility is not the issue. For the sake of argument, let&amp;#39;s go ahead and say I live in TEN mother&amp;#39;s basements... regardless of this, you either agree that &amp;quot;same markup&amp;quot; is a silly promise that a single browser maker can&amp;#39;t deliver on, or you ascribe to some other belief. I, anonymous Internet commenter, and my illustrious reputation, neither add weight to nor subtract weight from my simple argument.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10045104" width="1" height="1"&gt;</description></item><item><title>re: DOM Traversal</title><link>http://blogs.msdn.com/b/ie/archive/2010/07/30/dom-traversal.aspx#10045100</link><pubDate>Mon, 02 Aug 2010 20:09:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10045100</guid><dc:creator>rofl...</dc:creator><description>&lt;p&gt;Kiddo, defending yourself as a &amp;quot;SouthPark-watcher&amp;quot; isn&amp;#39;t going to win you a lot of credibility when someone accuses you of living in your parents&amp;#39; basement.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10045100" width="1" height="1"&gt;</description></item><item><title>re: DOM Traversal</title><link>http://blogs.msdn.com/b/ie/archive/2010/07/30/dom-traversal.aspx#10045083</link><pubDate>Mon, 02 Aug 2010 19:49:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10045083</guid><dc:creator>greenunicorns</dc:creator><description>&lt;p&gt;@NotLivingInMomsBasement&lt;/p&gt;
&lt;p&gt;Ah HA! It was a South Park reference to a Star Wars metaphor, which flags me as EXACTLY one of the hundreds of millions of people they&amp;#39;re trying to reach, and your failure to publicly recognize that flags you as somebody who has no right to be flagging me as a... em... I don&amp;#39;t know.&lt;/p&gt;
&lt;p&gt;Anyway, yes, they can attempt to adhere to other browsers&amp;#39; implementations IF there is a consensus, but they can do nothing for the cause of &amp;quot;same markup&amp;quot; if Opera, Firefox, and Safari are all handling something in different ways. The best they can manage in such a case is &amp;quot;Slightly Less Different Markup&amp;quot;. Don&amp;#39;t get me wrong, I applaud the efforts in the direction of coming back from Obscure Microsoft Island and joining the mainland where everybody else is, but it just sounds dumb for a browser team to be boasting that they are making their browser so that your HTML will work the same way in all browsers. It just doesn&amp;#39;t make sense. Did I mention Chewbacca?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10045083" width="1" height="1"&gt;</description></item><item><title>re: DOM Traversal</title><link>http://blogs.msdn.com/b/ie/archive/2010/07/30/dom-traversal.aspx#10044990</link><pubDate>Mon, 02 Aug 2010 16:34:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10044990</guid><dc:creator>NotLivingInMomsBasement</dc:creator><description>&lt;p&gt;@unicorn: They don&amp;#39;t need to control what the other browsers do-- they can simply test them. If there is consensus (spec or no) then they can match their behavior with IE9.&lt;/p&gt;
&lt;p&gt;Your choice of a Star Wars metaphor clearly flags you as NOT the sort of reader they&amp;#39;re optimizing for with the &amp;quot;same markup&amp;quot; slogan-- they&amp;#39;re trying to reach the hundreds of millions of more normal people who understand &amp;quot;same markup&amp;quot; == &amp;quot;good&amp;quot;... good for business, good for users, good for the web.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10044990" width="1" height="1"&gt;</description></item><item><title>re: DOM Traversal</title><link>http://blogs.msdn.com/b/ie/archive/2010/07/30/dom-traversal.aspx#10044931</link><pubDate>Mon, 02 Aug 2010 14:48:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10044931</guid><dc:creator>greenunicorns</dc:creator><description>&lt;p&gt;@Jim&lt;/p&gt;
&lt;p&gt;&amp;quot;Please stop with the &amp;quot;same markup&amp;quot; slogan. &amp;nbsp;JavaScript is not markup and it makes you look utterly clueless when you refer to it as such.&amp;quot;&lt;/p&gt;
&lt;p&gt;YES. Not to mention the fact that you can&amp;#39;t possibly engineer a single browser in a way that ensures that developers can write markup that will be rendered the same by the browsers you DON&amp;#39;T control.&lt;/p&gt;
&lt;p&gt;This was obviously the idea of some less-than-technical manager, and I&amp;#39;m sure the hard-working IE9 team is silently bearing the painful stupidity of this slogan. It makes about as much sense as Chewbacca living on Endor.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10044931" width="1" height="1"&gt;</description></item></channel></rss>