<?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>Eric Feminella</title>
	<atom:link href="http://www.ericfeminella.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ericfeminella.com/blog</link>
	<description>Thoughts on Software Design and Development</description>
	<lastBuildDate>Wed, 25 Jan 2012 04:12:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>AT&amp;T Best Practices Guide for App Development</title>
		<link>http://www.ericfeminella.com/blog/2012/01/15/att-best-practices-guide-for-app-development/</link>
		<comments>http://www.ericfeminella.com/blog/2012/01/15/att-best-practices-guide-for-app-development/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 11:00:20 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Mobile Web]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Tablets]]></category>
		<category><![CDATA[User Experience Design]]></category>

		<guid isPermaLink="false">http://www.ericfeminella.com/blog/?p=3419</guid>
		<description><![CDATA[When considering the various best practices surrounding the design of Mobile Web Experiences and Architectures, such works as the W3C&#8217;s Mobile Web Application Best Practices guide, or the excellent Mobile Web Best Practices site, and of course, the seminal text, Mobile First, are likely to come to mind. The concepts and strategies presented in these [...]]]></description>
			<content:encoded><![CDATA[<p>When considering the various best practices surrounding the design of Mobile Web Experiences and Architectures, such works as the W3C&#8217;s <a href="http://www.w3.org/TR/mwabp/" target="_blank">Mobile Web Application Best Practices</a> guide, or the excellent <a href="http://mobilewebbestpractices.com/" target="_blank">Mobile Web Best Practices</a> site, and of course, the seminal text, <a href="http://www.abookapart.com/products/mobile-first" target="_blank">Mobile First</a>, are likely to come to mind. The concepts and strategies presented in these works are a staple in the design of many modern Mobile Web Experiences and are without question an invaluable resource. In addition to these and other similarly related works, another new and valuable resource has been made available from a very important player in the Mobile Space indeed &#8211; an actual Wireless Carrier, AT&#038;T.</p>
<p>Recently, I was contacted by a representative of the AT&#038;T Developer Program informing me of the research conducted by the <a href="http://www.research.att.com/editions/201201_home.html?fbid=Mu13IZ0xu2h" target="_blank">AT&#038;T Research Labs</a> and, the subsequent resources made available by AT&#038;T as a result of their findings. Since I was unaware of this work, I was very interesting in learning more and, after reading the introductory statements, I was quite eager to apply AT&#038;T&#8217;s recommendations as well; to quote specifically:<br />
<blockquote>We quickly saw that a few, simple design approaches could significantly improve application responsiveness.</p></blockquote>
<p>Having read through the material in it&#8217;s entirety (provided <a href="#resources" target="_self">below</a>) I must say I am rather impressed. The information provided has very real and practical implications on the design of Mobile Web Applications. Specifically, I found the clear and concise explanation of the underlying implementation of the <a href="http://en.m.wikipedia.org/wiki/Radio_Resource_Control">Radio Resource Control (RRC) protocol</a> to be particularly relevant and useful. RRC is by far one of the most important design factors to consider in terms of battery life and Application responsiveness and, as the research suggests, this may not have been common knowledge. </p>
<p>By far, the most interesting and notable aspect of the AT&#038;T Research Lab&#8217;s work in this area is the fact that all of the information provided is applicable in the context of all Wireless Carriers, not just AT&#038;T. That is, the recommendations given, such as those regarding the RRC State Machine, for example, are all based on carrier-independent standards and protocols implemented by all Wireless Carriers. As such, understanding the implementation specifics and recommendations provided is certain to prove valuable for all users of your Application, regardless of their Carrier.</p>
<p>If you haven&#8217;t all ready, I highly recommend reading and applying the principles provided by AT&#038;T&#8217;s research to your current and future Mobile Web Application Designs.</p>
<h2 id="resources">AT&#038;T Research Labs: Mobile Application Resources</h2>
<p><a href="https://developer.att.com/developer/forward.jsp?passedItemId=7200042" target="_blank">Build Efficient Apps</a><br />
<a href="http://www.research.att.com/export/sites/att_labs/techdocs/TD_100229.pdf" target="_blank">Profiling Resource Usage for Mobile Applications: A Cross-layer Approach</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ericfeminella.com/blog/2012/01/15/att-best-practices-guide-for-app-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring iOS HTTP Monitoring</title>
		<link>http://www.ericfeminella.com/blog/2011/12/16/monitoring-http-traffic-on-ios/</link>
		<comments>http://www.ericfeminella.com/blog/2011/12/16/monitoring-http-traffic-on-ios/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 02:04:29 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Mobile Web]]></category>
		<category><![CDATA[Tablets]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[mobile web]]></category>
		<category><![CDATA[proxies]]></category>

		<guid isPermaLink="false">http://www.ericfeminella.com/blog/?p=3378</guid>
		<description><![CDATA[When developing Web Applications for the Mobile Web Experience it is often useful to have a clear view into all HTTP requests and responses sent between the client and server. This is quite simple to accomplish when developing Web Applications for the Desktop as, the browser is running locally so any standard HTTP Monitor will [...]]]></description>
			<content:encoded><![CDATA[<p>When developing Web Applications for the Mobile Web Experience it is often useful to have a clear view into all HTTP requests and responses sent between the client and server. This is quite simple to accomplish when developing Web Applications for the Desktop as, the browser is running locally so any standard HTTP Monitor will suffice. And, while it is a normal part of a typical development workflow to run an application locally the majority of the time, testing on each target device is obviously an essential part of the process as well.</p>
<p>Luckily, with <a href="http://www.charlesproxy.com/" target="_blank">Charles</a>, on iOS this is quite simple to accomplish.</p>
<h2>Configuration</h2>
<p>To configure Charles to proxy all requests from an iOS device, simply follow these basic steps:</p>
<ol>
<li>From your iOS Device, open Settings.</li>
<li>Go to Wi-Fi, select your Network and select the Blue &#8220;arrow&#8221; icon.</li>
<li>Scroll to HTTP Proxy and select the Manual Button.</li>
<li>In the Server field, enter the IP address of your development machine.</li>
<li>In the port field, enter port 8888 (the default port to which Charles binds).</li>
<li>Leave Authentication set to Off.</li>
</ol>
<p>And that&#8217;s all there is to it. Now, open Mobile Safari and go to your Web Application&#8217;s URL (or any page on the web for that matter). On your development machine, in Charles you will receive a prompt with the IP Address of your Mobile Device, click &#8220;Allow&#8221; and you are all set. When you are done working, make sure to turn off HTTP Proxy on your device.</p>
<h3>Additional Note</h3>
<p>While this article may be focused on Mobile Web Applications, these same configurations apply to all HTTP traffic from any application on your device that requires resources over the web. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ericfeminella.com/blog/2011/12/16/monitoring-http-traffic-on-ios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>External Templates in jQote2</title>
		<link>http://www.ericfeminella.com/blog/2011/12/12/external-templates-in-jqote2/</link>
		<comments>http://www.ericfeminella.com/blog/2011/12/12/external-templates-in-jqote2/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 12:00:56 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[APIs]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jqote2]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[templating]]></category>

		<guid isPermaLink="false">http://www.ericfeminella.com/blog/?p=3315</guid>
		<description><![CDATA[The jQote2 API Reference provides plenty of useful examples which are sure to help users get up and running quickly. I found it a bit unclear, though, as to how templates could be loaded externally as, in the reference examples, templates are defined within the containing page. For the sake of simplicity this approach certainly [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://aefxx.com/api/jqote2-reference/" target="_blank">jQote2 API Reference</a> provides plenty of useful examples which are sure to help users get up and running quickly. I found it a bit unclear, though, as to how templates could be loaded externally as, in the reference examples, templates are defined within the containing page. For the sake of simplicity this approach certainly makes sense in the context of examples. However, in practice, templates would ideally be loaded externally. </p>
<p>While <a href="http://aefxx.com/jquery-plugins/jqote2/" target="_blank">jQote2</a> provides a perfect API for templating, it does not provide a method specifically for loading external templates; this is likely due to the fact that loading external templates could easily be accomplished natively in <a href="http://jquery.com/" target="_blank">jQuery</a>. However, since this is a rather common development use case, having such a facility available would be quite useful.</p>
<p>After reviewing the comments I came across a nice example from <a href="http://aefxx.com/" target="_blank">aefxx</a> (the author of jQote2) which demonstrated a typical approach to loading external templates which was simular to what I had been implementing myself. </p>
<p>And so, I wrote a simple jQuery Plug-in which provides a tested, reusable solution to loading external templates. After having leveraged the Plugin on quite a few different projects, I decided to open source it as others may find it useful as well.</p>
<p>You can grab the source and view the example over on the <a href="https://github.com/efeminella/jqote2-template-loader">jQote2 Template Loader</a> Github page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ericfeminella.com/blog/2011/12/12/external-templates-in-jqote2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>DHTMLX Touch 1.0 Released</title>
		<link>http://www.ericfeminella.com/blog/2011/11/23/dhtmlx-touch-1-0-released/</link>
		<comments>http://www.ericfeminella.com/blog/2011/11/23/dhtmlx-touch-1-0-released/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 13:31:56 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Mobile Web]]></category>

		<guid isPermaLink="false">http://www.ericfeminella.com/blog/?p=3284</guid>
		<description><![CDATA[Last week, shortly after I blogged about the release of jQuery Mobile 1.0, I received an email informing me of the release of another Mobile Web Framework: DHTMLX Touch 1.0. Being that I was unfamiliar with DHTMLX Touch (as I have been using jQuery Mobile almost exclusively), I was quite interested to learn more; and, [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, shortly after I blogged about the release of <a href="http://www.ericfeminella.com/blog/2011/11/17/jquery-mobile-1-0-released/" target="_blank">jQuery Mobile 1.0</a>, I received an email informing me of the release of another Mobile Web Framework: <a href="http://www.dhtmlx.com/touch/" target="_blank">DHTMLX Touch 1.0</a>. </p>
<p>Being that I was unfamiliar with <em>DHTMLX Touch</em> (as I have been using <a href="http://jquerymobile.com/" target="_blank">jQuery Mobile</a> almost exclusively), I was quite interested to learn more; and, having tried the <a href="http://www.dhtmlx.com/touch/samples/" target="_blank">Examples</a> and reviewed the <a href="http://docs.dhtmlx.com/touch/" target="_blank">Documentation</a>, I was rather impressed by DHTMLX Touch. </p>
<p>And so, if you haven&#8217;t already, <a href="http://www.dhtmlx.com/blog/?p=1425" target="_blank">check it out</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ericfeminella.com/blog/2011/11/23/dhtmlx-touch-1-0-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function Overwriting in JavaScript</title>
		<link>http://www.ericfeminella.com/blog/2011/11/19/function-overwriting-in-javascript/</link>
		<comments>http://www.ericfeminella.com/blog/2011/11/19/function-overwriting-in-javascript/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 19:45:40 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Object Oriented Design]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.ericfeminella.com/blog/?p=3129</guid>
		<description><![CDATA[Whether intentional, or simply a by-product of it&#8217;s design, Javascript, being a dynamic language, allows for a level of expressiveness which most any seasoned programmer would come to appreciate. Javascript naturally provides the ability to implement some rather intriguing and quite unique patterns; one of which is the ability to overwrite a function at runtime. [...]]]></description>
			<content:encoded><![CDATA[<p>Whether intentional, or simply a by-product of it&#8217;s design, Javascript, being a <a href="http://en.wikipedia.org/wiki/Dynamic_programming_language" target="_blank">dynamic language</a>, allows for a level of expressiveness which most any seasoned programmer would come to appreciate. Javascript naturally provides the ability to implement some rather intriguing and quite unique patterns; one of which is the ability to overwrite a function at runtime.</p>
<section>
<h2>Function Overwriting</h2>
<p><em>Function Overwriting</em> (also known as &#8220;Self-Defining Functions&#8221; or &#8220;Lazy Defining Functions&#8221;) provides a pattern which, as stated above, allows for overwriting a function&#8217;s definition at runtime. This can be accomplished from outside of the function, but also from within the function&#8217;s implementation itself.</p>
<p>For example, on occasion a function may need to perform some initial piece of work, after which, all subsequent invocations would result in unnecessarily re-executing the initialization code. Typically, this issue is addressed by storing initialization flags or refactoring the initialization code to another function. While such a design solves this problem, it does result in unnecessary code which will need to be maintained. In JavaScript, perhaps a different approach is in order: we can simply redefine the function after the initialization work has been completed.</p>
<p>A possible candidate use-case for Function Overwriting is Feature Detection as, detecting for specific feature support in the Browser typically only needs to be tested once, at which point subsequent tests are unnecessary. </p>
<p>Below is a basic example of implementing <em>Function Overwritting</em> in the context of an abstraction of the <a href="http://dev.w3.org/geo/api/spec-source.html" title="HTML5 Geolocation" target="_blank">HTML5 Geolocation</a> API.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="co1">// Initial &quot;getLocation&quot; implementation. Since we only need to test</span><br />
<span class="co1">// for Geolocation support once, we perform the initial test and then</span><br />
<span class="co1">// overwrite the &quot;getLocation&quot; implementation based on the results of</span><br />
<span class="co1">// the test.</span><br />
<span class="kw2">var</span> getLocation = <span class="kw2">function</span> <span class="br0">&#40;</span> success, fail, options <span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw2">var</span> geolocation = navigator.<span class="me1">geolocation</span>;</p>
<p>&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> geolocation <span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> _options = <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; enableHighAccuracy : <span class="kw2">true</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timeout &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;: <span class="nu0">60000</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; maximumAge &nbsp; &nbsp; &nbsp; &nbsp; : <span class="nu0">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Geolocation is supported, so we overwrite the implementation</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// to simply invoke &quot;geolocation.getCurrentPosition&quot; as there </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// is no need to perform the test again.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; getLocation = <span class="kw2">function</span> <span class="br0">&#40;</span>success, fail, options<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; geolocation.<span class="me1">getCurrentPosition</span> <span class="br0">&#40;</span> success, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fail, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; options || _options<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; getLocation<span class="br0">&#40;</span> success, fail, options <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">else</span> <br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Geolocation is not supported, so we overwrite the </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// implementation to simply return false (a real </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// implementation might provide a polyfill here&#8230;).</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; getLocation = <span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span>&nbsp; &nbsp;&nbsp; &nbsp; <br />
<span class="br0">&#125;</span>;</div>
</section>
<section>
<h2>Considerations</h2>
<p>Since functions are objects in Javascript, it is important to keep in mind that if you add a property or method to a function (either statically or via the function&#8217;s prototype), and then overwrite the function, you will have effectively removed those properties or methods as well. Also, if the function is referenced by another variable, or by a method of another object, the initially defined implementation will be preserved and the overwriting process will not occur. As such, be mindful when implementing this pattern. As a general rule of thumb, I typically only implement Function Overwriting when the function being redefined is in a private scope.<br />
</section>
<section>
<h2>Concluding Thoughts</h2>
<p>As you can see, Function Overwriting provides a convenient facility for optimizing code execution at runtime. There are many use-cases for dynamically overwriting functions and, where appropriate, they can certainly provide value in terms of performance and code maintainability. </p>
<p>Below you can find an example which demonstrates two basic <em>Function Overwriting</em> implementations. Simply load the page and add some breakpoints in Firebug to test the execution paths; both before and after overwriting each function occurs, or you can simply view the source.<br />
<a href="http://code.ericfeminella.com/articles/examples/js/function-overwritting/" title="Function Overwriting Example" target="_blank">Example</a><br />
</section>
]]></content:encoded>
			<wfw:commentRss>http://www.ericfeminella.com/blog/2011/11/19/function-overwriting-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Refreshing listviews in jQuery Mobile</title>
		<link>http://www.ericfeminella.com/blog/2011/11/18/jquery-mobile-listviewrefresh/</link>
		<comments>http://www.ericfeminella.com/blog/2011/11/18/jquery-mobile-listviewrefresh/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 03:42:01 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[APIs]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery Mobile]]></category>

		<guid isPermaLink="false">http://www.ericfeminella.com/blog/?p=3168</guid>
		<description><![CDATA[When dynamically creating or updating a list in jQuery Mobile; either via AJAX or by other means, one must take care to explicitly invoke the target listview widget to &#8220;refresh&#8221; in order to instruct the framework to apply the augmented markup and styles to the corresponding elements of the underlying list. For example, consider the [...]]]></description>
			<content:encoded><![CDATA[<p>When dynamically creating or updating a <code>list</code> in jQuery Mobile; either via AJAX or by other means, one must take care to explicitly invoke the target <a href="https://github.com/jquery/jquery-mobile/blob/master/js/jquery.mobile.listview.js" target="_blank">listview widget</a> to <em>&#8220;refresh&#8221;</em> in order to instruct the framework to apply the augmented markup and styles to the corresponding elements of the underlying list.</p>
<p>For example, consider the following simplified example which creates an <code>li</code> element for each item in an <code>Array</code>:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">var</span> list = <span class="st0">&quot;&quot;</span>,<br />
&nbsp; &nbsp; items = <span class="br0">&#91;</span><span class="br0">&#123;</span><span class="kw3">name</span>: <span class="st0">&quot;Item A&quot;</span>, url: <span class="st0">&quot;/#item-a&quot;</span><span class="br0">&#125;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#123;</span><span class="kw3">name</span>: <span class="st0">&quot;Item B&quot;</span>, url: <span class="st0">&quot;/#item-b&quot;</span><span class="br0">&#125;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#123;</span><span class="kw3">name</span>: <span class="st0">&quot;Item C&quot;</span>, url: <span class="st0">&quot;/#item-c&quot;</span><span class="br0">&#125;</span><span class="br0">&#93;</span>;</p>
<p>$.<span class="me1">each</span><span class="br0">&#40;</span> items, <span class="kw2">function</span><span class="br0">&#40;</span> i, <span class="kw1">item</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; list += <span class="st0">&#8216;&lt;li&gt;&lt;a href=&quot;&#8217;</span> + <span class="kw1">item</span>.<span class="me1">url</span> + <span class="st0">&#8216;&quot;&gt;&#8217;</span> + <span class="kw1">item</span>.<span class="kw3">name</span> +<span class="st0">&#8216;&lt;/a&gt;&lt;/li&gt;&#8217;</span>;<br />
<span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
$<span class="br0">&#40;</span><span class="st0">&quot;ul:jqmData(role=&#8217;listview&#8217;)&quot;</span><span class="br0">&#41;</span>.<span class="me1">append</span><span class="br0">&#40;</span> list <span class="br0">&#41;</span>;</div>
<p>While this will create the list items and add them to the target <code>listview</code> <code>ul</code> element, JQM will not auto enhance the newly added items unless instructed to do so. I imagine this is due to a necessary design decision as, constantly monitoring the DOM for changes would certainly incur a performance hit.</p>
<p>In order to correct this, we just need to invoke <code>.listview("refresh");</code> after appending the new elements to the list. This will notify <em>JQM</em> to apply the expected enhancements. And so, the following example will result in the expected list enhancements being applied:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">var</span> list = <span class="st0">&quot;&quot;</span>,<br />
&nbsp; &nbsp; items = <span class="br0">&#91;</span><span class="br0">&#123;</span><span class="kw3">name</span>: <span class="st0">&quot;Item A&quot;</span>, url: <span class="st0">&quot;/#item-a&quot;</span><span class="br0">&#125;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#123;</span><span class="kw3">name</span>: <span class="st0">&quot;Item B&quot;</span>, url: <span class="st0">&quot;/#item-b&quot;</span><span class="br0">&#125;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#123;</span><span class="kw3">name</span>: <span class="st0">&quot;Item C&quot;</span>, url: <span class="st0">&quot;/#item-c&quot;</span><span class="br0">&#125;</span><span class="br0">&#93;</span>;</p>
<p>$.<span class="me1">each</span><span class="br0">&#40;</span> items, <span class="kw2">function</span><span class="br0">&#40;</span> i, <span class="kw1">item</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; list += <span class="st0">&#8216;&lt;li&gt;&lt;a href=&quot;&#8217;</span> + <span class="kw1">item</span>.<span class="me1">url</span> + <span class="st0">&#8216;&quot;&gt;&#8217;</span> + <span class="kw1">item</span>.<span class="kw3">name</span> +<span class="st0">&#8216;&lt;/a&gt;&lt;/li&gt;&#8217;</span>;<br />
<span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
$<span class="br0">&#40;</span><span class="st0">&quot;ul:jqmData(role=&#8217;listview&#8217;)&quot;</span><span class="br0">&#41;</span>.<span class="me1">append</span><span class="br0">&#40;</span> list <span class="br0">&#41;</span>.<span class="me1">listview</span><span class="br0">&#40;</span><span class="st0">&quot;refresh&quot;</span><span class="br0">&#41;</span>;</div>
<p>You can try an example which demonstrates both of the above implementations <a href="http://code.ericfeminella.com/articles/examples/jqm/listview/index.html" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ericfeminella.com/blog/2011/11/18/jquery-mobile-listviewrefresh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Mobile 1.0 Released</title>
		<link>http://www.ericfeminella.com/blog/2011/11/17/jquery-mobile-1-0-released/</link>
		<comments>http://www.ericfeminella.com/blog/2011/11/17/jquery-mobile-1-0-released/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 16:45:20 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[iPad]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Mobile Web]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Tablets]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[jqm]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jQuery Mobile]]></category>
		<category><![CDATA[jquery ui]]></category>
		<category><![CDATA[mobile web]]></category>

		<guid isPermaLink="false">http://www.ericfeminella.com/blog/?p=2903</guid>
		<description><![CDATA[Today, the jQuery Mobile Team announced the official release of jQuery Mobile 1.0. Having worked with jQuery Mobile since Alpha 1, in the time since, the framework has certainly evolved into a mature, premier platform on which Mobile Web Applications can be built. On a personal note, as I am currently in the process of [...]]]></description>
			<content:encoded><![CDATA[<p><time datetime="2011-11-17">Today</time>, the jQuery Mobile Team announced the official release of <a href="http://jquerymobile.com/blog/2011/11/16/announcing-jquery-mobile-1-0/" target="_blank">jQuery Mobile 1.0</a>. </p>
<p>Having worked with jQuery Mobile since <a href="http://jquerymobile.com/demos/1.0a1/" target="_blank">Alpha 1</a>, in the time since, the framework has certainly evolved into a mature, premier platform on which Mobile Web Applications can be built. </p>
<p>On a personal note, as I am currently in the process of working towards the release of a multi form-factor Mobile Web Application built on jQuery Mobile, the <em>1.0</em> release couldn&#8217;t have come at a better time.</p>
<p>Be sure to check out the updated <a href="http://jquerymobile.com/demos/1.0/" title="jQuery Mobile 1.0 API Documentation" target="_blank">API Docs</a>, especially the new <a href="http://jquerymobile.com/test/docs/api/data-attributes.html" target="_blank">Data Attributes</a> section.</p>
<p>jQuery Mobile 1.0 represents a <strong>significant milestone</strong> in the <em>Mobile Web Space</em>. I am certainly excited to see what is on the roadmap next.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ericfeminella.com/blog/2011/11/17/jquery-mobile-1-0-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS3 Combinators</title>
		<link>http://www.ericfeminella.com/blog/2011/11/13/css3-combinators/</link>
		<comments>http://www.ericfeminella.com/blog/2011/11/13/css3-combinators/#comments</comments>
		<pubDate>Sun, 13 Nov 2011 11:51:52 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mobile Web]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[css3 combinators]]></category>
		<category><![CDATA[CSS3 Selectors]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[selectors]]></category>

		<guid isPermaLink="false">http://www.ericfeminella.com/blog/?p=3016</guid>
		<description><![CDATA[In my previous article on CSS3 Selectors, I discussed the two Attribute Selector classifications; Attribute Presence and Value Selectors, and, Attribute Substring Matching Selectors. In addition to the new Attribute Selectors, the CSS3 Selectors Module defines a new Combinator called the General sibling combinator, which is described below, succeeding a review of each CSS3 Combinator. [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous article on CSS3 Selectors, I discussed the two <em>Attribute Selector</em> classifications; <a href="http://http://www.ericfeminella.com/blog/2011/11/10/css3-attribute-selectors/#attribute-presence-value-selectors" target="_blank">Attribute Presence and Value Selectors</a>, and, <a href="http://www.ericfeminella.com/blog/2011/11/10/css3-attribute-selectors/#attribute-substring-matching-selectors" target="_blank">Attribute Substring Matching Selectors</a>.</p>
<p>In addition to the new Attribute Selectors, the <a href="http://www.w3.org/TR/css3-selectors/" target="_blank">CSS3 Selectors Module</a> defines a new <em>Combinator</em> called the <strong>General sibling combinator</strong>, which is described below, succeeding a review of each CSS3 <em>Combinator</em>.</p>
<section>
<h2>Combinators</h2>
<p>Combinators provide a means for describing relationships between elements in order to &#8220;combine&#8221; them to form specific rules based on a simple syntax. There are four Combinators in CSS3, below is description and example of each:</p>
<div class="post-datalist">
<dl>
<dt>Descendant combinator</dt>
<dd>The most familiar of all Combinators, the <em>Descendant combinator</em> allows for selecting any element <em>f</em> which is a descendant (child, grandchild, great-grandchild and so on) of an element <em>e</em>. The combinator syntax for a Descendant combinator is a single &#8220;white-space&#8221; character.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="coMULTI">/* Matches all &lt;h1&gt; elements which are descendants of an &lt;article&gt; element */</span><br />
article h1<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="coMULTI">/* declarations */</span><br />
<span class="br0">&#125;</span></div>
<p><a href="http://www.w3.org/TR/selectors/#descendant-combinators" target="_blank">8.1. Descendant combinator</a>
</dd>
<dt>Child combinators</dt>
<dd><em>Child combinators</em> allow for selecting any element <em>f</em> which is a direct child of an element <em>e</em>. The combinator syntax for a <em>Child combinator</em> is a single &#8220;greater-than&#8221; (&gt;) sign.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="coMULTI">/* Matches each &lt;section&gt; element that is a direct child of an &lt;article&gt; element */</span><br />
article &gt; section <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="coMULTI">/* declarations */</span><br />
<span class="br0">&#125;</span></div>
<p><a href="http://www.w3.org/TR/selectors/#child-combinators" target="_blank">8.2. Child combinator</a>
</dd>
<dt>Adjacent sibling combinator</dt>
<dd>The <em>Adjacent sibling combinator</em> is a <em>Sibling combinator</em> which allows for selecting an element <em>f</em> which is adjacent to an element <em>e</em>; that is, element <em>f</em> immediately follows element <em>e</em> in the document tree. The combinator syntax for an <em>Adjacent sibling combinator</em> is a single &#8220;plus&#8221; (+) sign.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="coMULTI">/* Matches all &lt;em&gt; elements which are the next sibling of a &lt;strong&gt; element */</span><br />
strong + em <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="coMULTI">/* declarations */</span><br />
<span class="br0">&#125;</span></div>
<p><a href="http://www.w3.org/TR/selectors/#adjacent-sibling-combinators" target="_blank">8.3.1. Adjacent sibling combinator</a>
</dd>
<dt>General sibling combinator</dt>
<dd>New in CSS3, the <em>General sibling combinator</em> is similar to the <em>Adjacent sibling combinator</em> in that it matches an element <em>f</em> which follows an element <em>e</em> in the document tree; however, whereas in the <em>Adjacent sibling combinator</em> element <em>f</em> must immediately follow element <em>e</em>, the <em>General sibling combinator</em> allows for selecting an element <em>f</em> which is preceded by an element <em>e</em>, but not necessarily immediately preceded by an element <em>e</em>. The combinator syntax for a <em>General sibling combinator</em> is a single &#8220;tilde&#8221; (~) sign.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="coMULTI">/* Matches all &lt;time&gt; elements which are preceded by a &lt;del&gt; element */</span><br />
del ~ time <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="coMULTI">/* declarations */</span><br />
<span class="br0">&#125;</span></div>
<p><a href="http://www.w3.org/TR/selectors/#general-sibling-combinators" target="_blank">8.3.2. General sibling combinator</a>
</dd>
</dl>
<p>The following link provides a (rather crude in terms of design) example of each Combinator described above:<br />
<a href="http://code.ericfeminella.com/articles/examples/css3/selectors/combinators.html" target="_blank" title="CSS3 Combinators Example">View Example</a>
</div>
</section>
]]></content:encoded>
			<wfw:commentRss>http://www.ericfeminella.com/blog/2011/11/13/css3-combinators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS3 Attribute Selectors</title>
		<link>http://www.ericfeminella.com/blog/2011/11/10/css3-attribute-selectors/</link>
		<comments>http://www.ericfeminella.com/blog/2011/11/10/css3-attribute-selectors/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 15:59:33 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Mobile Web]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[CSS3 Attribute Selectors]]></category>
		<category><![CDATA[CSS3 Selectors]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[html5 elements]]></category>
		<category><![CDATA[html5 semantics]]></category>

		<guid isPermaLink="false">http://www.ericfeminella.com/blog/?p=2937</guid>
		<description><![CDATA[The power of CSS Selectors can not be understated; for, without them, there would be no simple means by which developers could target specific elements for styling in a manner abstracted from, or external to, the actual markup to which the styles will bind. In addition to some of the more common Simple Selectors, such [...]]]></description>
			<content:encoded><![CDATA[<p>The power of <a href="http://www.w3.org/TR/selectors/" title="CSS3 Selectors Module" target="_blank">CSS Selectors</a> can not be understated; for, without them, there would be no simple means by which developers could target specific elements for styling in a manner abstracted from, or external to, the actual markup to which the styles will bind.</p>
<p>In addition to some of the more common <a href="http://www.w3.org/TR/selectors/#simple-selectors" title="CSS3 Simple Selectors" target="_blank">Simple Selectors</a>, such as <a href="http://www.w3.org/TR/selectors/#type-selectors" title="CSS3 Type Selectors" target="_blank">Type Selectors</a>, <a href="http://www.w3.org/TR/selectors/#class-html" title="CSS3 Class Selectors" target="_blank">Class Selectors</a> and <a href="http://www.w3.org/TR/selectors/#id-selectors" title="CSS3 Id Selectors" target="_blank">Id Selectors</a>, we have have <a href="http://www.w3.org/TR/selectors/#attribute-selectors" title="CSS3 Attribute Selectors" target="_blank">Attribute Selectors</a>, which, as the name implies, allow us to match elements based on their <a href="http://dev.w3.org/html5/spec/Overview.html#attributes" title="HTML5 Element Attributes" target="_blank">attributes</a>.</p>
<section id="attribute-presence-value-selectors">
<h2>Attribute Presence and Value Selectors</h2>
<p>CSS2 introduced four Attribute Selectors; referred to as <em>Attribute Presence and Value Selectors</em>, which allow for course grained matching of specific elements based on their attributes and / or attribute values. These include the following:</p>
<div class="post-datalist">
<dl>
<dt>e[attr]</dt>
<dd>Where <em>e</em> is an element and <code>[attr]</code> is an attribute of element <em>e</em>. For example, <code>p[title]</code> would match all <code>p</code> tags with a <code>title</code>, regardless of the value of the <code>title</code>.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="coMULTI">/* Matches all &lt;p&gt; tags with a title and changes their background color to red with white text */</span><br />
p<span class="br0">&#91;</span>title<span class="br0">&#93;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; background-color: red;<br />
&nbsp; &nbsp; color: white;<br />
<span class="br0">&#125;</span></div>
</dd>
<dt>e[attr=val]</dt>
<dd>Where <em>e</em> is an element and <code>[attr=val]</code> represent an attribute of element <em>e</em> which contains the exact value of <code>val</code>. For example, <code>p[title="Example 1"]</code> would match all <code>p</code> tags with a <code>title</code> which equals &#8220;Example 1&#8243; exactly.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="coMULTI">/* Matches all &lt;p&gt; tags with a title equal to &quot;Example 1&quot; and changes their background color to green and text color to white */</span><br />
p<span class="br0">&#91;</span>title=<span class="st0">&quot;Example 1&quot;</span><span class="br0">&#93;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; background-color: green;<br />
&nbsp; &nbsp; color: white;<br />
<span class="br0">&#125;</span></div>
</dd>
<dt>e[attr~=val]</dt>
<dd>Where <em>e</em> is an element and <code>[attr~=val]</code> is an attribute of element <em>e</em> which has a value containing a whitespace-separated list of words, one of which equals <code>val</code> exactly. For example, <code>p[title~="Example-1a"]</code> would match all <code>p</code> tags with a <code>title</code> containing the word &#8220;Example-1a&#8221; in a list of whitespace delimited words.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="coMULTI">/* Matches all &lt;p&gt; tags with a title containing the exact word to &quot;Example-1a&quot; and changes their background color to black and text color to red */</span><br />
p<span class="br0">&#91;</span>title~=<span class="st0">&quot;Example-1a&quot;</span><span class="br0">&#93;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; background-color: black;<br />
&nbsp; &nbsp; color: red;<br />
<span class="br0">&#125;</span></div>
</dd>
<dt>e[attr|=val]</dt>
<dd>Where <em>e</em> is an element and <code>[attr|=val]</code> is an attribute of element <em>e</em> that has a value of <code>val</code> exactly, or begins with <code>val</code> immediately followed by a hyphen &#8220;-&#8221;. For example, <code>p[title!="Example"]</code> would match all <code>p</code> tags with a <code>title</code> containing the word &#8220;Example-&#8221;, followed by any other value, such as &#8220;Example-1&#8243;, &#8220;Example-A&#8221;, etc..</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="coMULTI">/* Matches all &lt;p&gt; tags with a title containing the word to &quot;Example-&quot; and changes their background color to blue and text color to white */</span><br />
p<span class="br0">&#91;</span>title|=<span class="st0">&quot;Example&quot;</span><span class="br0">&#93;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; background-color: blue;<br />
&nbsp; &nbsp; color: white;<br />
<span class="br0">&#125;</span></div>
</dd>
</dl>
<p><a href="http://code.ericfeminella.com/articles/examples/css3/selectors/attribute-presence.html" target="_blank" title="Attribute Presence and Value Selectors Example">View Example</a>
</div>
</section>
<section id="attribute-substring-matching-selectors">
<h2>Substring Matching Attribute Selectors</h2>
<p>In addition to the above <em>Attribute Presence and Value Selectors</em>, CSS3 expands on this by defining three additional <a href="http://www.w3.org/TR/selectors/#attribute-substrings" target="_blank">Attribute Selectors</a>; referred to as <em>Substring Matching Attribute Selectors</em>. These additions allow for fine grained matching of specific elements based on their attribute values. </p>
<p>In simplest terms, the new Attribute Selectors in CSS3 can be used to match an element with a given attribute whose value begins, ends or contains a certain value. The following is a basic description and example of each new Attribute Selector:</p>
<div class="post-datalist">
<dl>
<dt>e[attr^=val]</dt>
<dd>Where <em>e</em> is an element and <code>[attr^=val]</code> is an attribute of element <em>e</em> which contains a value that begins with <em>val</em>. </p>
<div class="dean_ch" style="white-space: wrap;">
<span class="coMULTI">/* Matches all linked resources sent over https */</span><br />
a<span class="br0">&#91;</span>href^=<span class="st0">&quot;https&quot;</span><span class="br0">&#93;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; color: red;<br />
<span class="br0">&#125;</span></div>
</dd>
<dt>e[attr$=val]</dt>
<dd>Where <em>e</em> is an element and <code>[attr$=val]</code> represent an attribute of element <em>e</em> which contains a value that ends with <code>val</code>.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="coMULTI">/* Matches all anchor tags to .html documents */</span><br />
a<span class="br0">&#91;</span>href$=<span class="st0">&quot;.html&quot;</span><span class="br0">&#93;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; color: green;<br />
<span class="br0">&#125;</span></div>
</dd>
<dt>e[attr*=val]</dt>
<dd>Where <em>e</em> is an element and <code>[attr*=val]</code> is an attribute of element <em>e</em> which has a value that contains <code>val</code>.</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="coMULTI">/* Matches all anchor tags which contain a query string */</span><br />
a<span class="br0">&#91;</span>href*=<span class="st0">&quot;?&quot;</span><span class="br0">&#93;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; color: blue;<br />
<span class="br0">&#125;</span></div>
</dd>
</dl>
<p><a href="http://code.ericfeminella.com/articles/examples/css3/selectors/substring-matching.html" target="_blank" title="Substring Matching Attribute Selectors Example">View Example</a>
</div>
</section>
<p>To summarize, there are a total of seven Attribute Selectors in CSS3, three of which are new. Whether used for general matches, such as global Attributes; e.g. <code>*[hreflang|=en]</code> or more specific matches, such as chaining; e.g, <code>a[href^="https"][target="_blank"]</code>, Attribute Selectors provide a powerful mechanism for selecting both general and specific content within a page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ericfeminella.com/blog/2011/11/10/css3-attribute-selectors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS3 selection pseudo-element (dropped)</title>
		<link>http://www.ericfeminella.com/blog/2011/11/02/css3-selection-colors/</link>
		<comments>http://www.ericfeminella.com/blog/2011/11/02/css3-selection-colors/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 06:23:32 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[CSS3]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[UI design]]></category>

		<guid isPermaLink="false">http://www.ericfeminella.com/blog/2011/10/25/css3-selection-colors/</guid>
		<description><![CDATA[With both the CSS3 Selectors and CSS3 Namespaces Modules, respectively, having been released as official W3C recommendations (Selectors, Namespaces), I felt compelled to re-review each specification. Interestingly, while reviewing the CSS3 Selectors Module (my personal favorite), I noticed that the selection pseudo-element selector which was originally drafted for CSS3 had been dropped from the proposal. [...]]]></description>
			<content:encoded><![CDATA[<p>With both the <a href="http://www.w3.org/TR/css3-selectors/" target="_blank">CSS3 Selectors</a> and <a href="http://www.w3.org/TR/css3-namespace/" target="_blank">CSS3 Namespaces</a> Modules, respectively, having been released as official W3C recommendations (<cite><a href="http://www.w3.org/TR/2011/REC-css3-selectors-20110929/" target="_blank">Selectors</a>, <a href="http://www.w3.org/TR/2011/REC-css3-namespace-20110929/" target="_blank">Namespaces</a></cite>), I felt compelled to re-review each specification. </p>
<p>Interestingly, while reviewing the CSS3 Selectors Module (my personal favorite), I noticed that  the <code><a href="http://www.w3.org/TR/css3-selectors/#selection" target="_blank">selection</a></code> pseudo-element selector which was originally drafted for CSS3 had been dropped from the proposal. In fact, it was dropped a rather long time ago.</p>
<p>In case you are not familiar with the <code>selection</code> pseudo-element, essentially it allows for defining the text <code>color</code> and <code>background-color</code> of selected text within a document. </p>
<p>For example, all <code>&lt;code&gt;</code> elements on my site have a red background with white text when selected &#8211; <code>such as this text here (select it)</code> &#8211; based on the following two simple rules:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="co1">// IE, Chrome, Safari, Opera</span><br />
code::selection <span class="br0">&#123;</span> background: #ca3131; color:#fff; <span class="br0">&#125;</span><br />
code::-moz-selection <span class="br0">&#123;</span> background: #ca3131; color:#fff; <span class="br0">&#125;</span></div>
<p>And so, while having been dropped, support is already rather good (FF3.6, SA3.1+, OP9.5+, CH2+, IE9) and as far as I am aware Browser vendors will continue to <cite><a href="https://developer.mozilla.org/En/CSS/%3A%3Aselection" target="_blank">support ::selection</a></cite>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ericfeminella.com/blog/2011/11/02/css3-selection-colors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Structural Elements</title>
		<link>http://www.ericfeminella.com/blog/2011/10/19/html5-structural-elements/</link>
		<comments>http://www.ericfeminella.com/blog/2011/10/19/html5-structural-elements/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 22:37:11 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[User Experience Design]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[html5 semantic]]></category>
		<category><![CDATA[html5 semantic structure]]></category>
		<category><![CDATA[html5 tags]]></category>

		<guid isPermaLink="false">http://www.ericfeminella.com/blog/?p=2589</guid>
		<description><![CDATA[The Semantic Web is not a separate Web but an extension of the current one, in which information is given well-defined meaning, better enabling computers and people to work in cooperation. - Tim Berners-Lee The HTML5 Specification introduces many new semantic elements intended to provide meaning to the structure of a document. These elements are [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>The Semantic Web is not a separate Web but an extension of the current one, in which information is given well-defined meaning, better enabling computers and people to work in cooperation.<br />
- Tim Berners-Lee</p></blockquote>
<p>The <a href="http://dev.w3.org/html5/spec/Overview.html" target="_blank">HTML5 Specification</a> introduces many new <a href="http://dev.w3.org/html5/spec-author-view/elements.html#semantics-0" target="_blank">semantic</a> elements intended to provide meaning to the structure of a document. These elements are quite important as they allow for marking up a document in meaningful ways which, prior to HTML5, would have otherwise required a rather ambiguous markup consisting primarily of <code>divs</code> and <code>ids</code> to provide semantic structure.</p>
<p>Being purely markup based, it is understandable why these new semantic elements may not excite as much interest as many of the more attention grabbing HTML5 specifications, such as <a href="http://dev.w3.org/html5/spec/Overview.html#the-audio-element" target="_blank">audio</a>, <a href="http://dev.w3.org/html5/spec/Overview.html#the-video-element" target="_blank">video</a>, <a href="http://dev.w3.org/html5/workers/" target="_blank">Web Workers</a>, <a href="http://dev.w3.org/html5/websockets/" target="_blank">WebSockets</a>, <a href="http://dev.w3.org/html5/webstorage/" target="_blank">Web Storage</a> etc. However, it is important, perhaps even necessary, to emphasize the significance these new elements present in terms of helping to solidify the realization of what the web is intended to be: an open medium for disseminating homogeneous and heterogeneous information. </p>
<p>With this in mind, combined with an informed understanding of the context in which each new semantic element can be applied, overtime the Web will (quite naturally) evolve in many new, exciting and perhaps previously unthought-of ways.</p>
<p>Broadly, the new semantic elements introduced in HTML5 can be succinctly summarized as follows:</p>
<div class="post-datalist">
<dl>
<dt>The &lt;header&gt; Element</dt>
<dd>
The <code>&lt;header&gt;</code> element is rather self explanatory in that it allows for defining content which is to be denoted as a header of a page, or a header within a section of a page. Headers typically provide introductory and / or navigational content via <a href="http://dev.w3.org/html5/spec/Overview.html#the-hgroup-element" target="_blank">hgroup</a> and nav elements. What is important to keep in mind is that multiple <code>&lt;header&gt;</code> elements can be defined per page.</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;header&gt;<br />
&nbsp; &nbsp; &lt;h1&gt;Some Blog&lt;/h1&gt;<br />
&nbsp; &nbsp; &lt;h2&gt;Some Blog Description&lt;/h2&gt;<br />
&nbsp; &nbsp; &lt;p&gt;Last Modified: &lt;time&gt;<span class="nu0">2011</span><span class="nu0">-10</span><span class="nu0">-19</span>&lt;<span class="re0">/time&gt;&lt;/</span>p&gt;<br />
&lt;/header&gt;<br />
&nbsp;</div>
<p><a href="http://dev.w3.org/html5/spec/Overview.html#the-header-element" target="_blank">W3C Specification</a> (section 4.4.8)
</dd>
<dt>The &lt;nav&gt; Element</dt>
<dd>
The <code>&lt;nav&gt;</code> element represents an important section of navigational links to specific pages or specific sections within the current page. As such, not all navigational links need be defined within a <code>&lt;nav&gt;</code>.</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;header&gt;<br />
&nbsp; &nbsp; &lt;h1&gt;Some Blog&lt;/h1&gt;<br />
&nbsp; &nbsp; &lt;h2&gt;Some Blog Description&lt;/h2&gt;<br />
&nbsp; &nbsp; &lt;p&gt;Last Modified: &lt;time&gt;<span class="nu0">2011</span><span class="nu0">-10</span><span class="nu0">-19</span>&lt;<span class="re0">/time&gt;&lt;/</span>p&gt;<br />
&nbsp; &nbsp; &lt;nav&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Navigation&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;ul&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=<span class="st0">&quot;home.php&quot;</span>&gt;Home&lt;<span class="re0">/a&gt;&lt;/</span>li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=<span class="st0">&quot;about.php&quot;</span>&gt;About&lt;<span class="re0">/a&gt;&lt;/</span>li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=<span class="st0">&quot;contact.php&quot;</span>&gt;Contact&lt;<span class="re0">/a&gt;&lt;/</span>li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/ul&gt;<br />
&nbsp; &nbsp; &lt;/nav&gt;<br />
&lt;/header&gt;</div>
<p><a href="http://dev.w3.org/html5/spec/Overview.html#the-nav-element" target="_blank">W3C Specification</a> (section 4.4.3)
</dd>
<dt>The &lt;article&gt; Element</dt>
<dd>The <code>&lt;article&gt;</code> element provides a means by which content can be represented independently from the document or application with which it is associated. General examples could include, as one may have guessed, an article from a newspaper, a blog post, a comment on a blog post, a self contained UI widget, and so forth.</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;article&gt;<br />
&nbsp; &nbsp; &lt;header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Some Post&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;time pubdate&gt;<span class="nu0">2011</span><span class="nu0">-10</span><span class="nu0">-02</span>&lt;<span class="re0">/time&gt;&lt;/</span>p&gt;<br />
&nbsp; &nbsp; &lt;/header&gt;<br />
&nbsp; &nbsp; &lt;p&gt;This <span class="kw1">is</span> a simple example of the article element.&lt;/p&gt;<br />
&nbsp; &nbsp; &lt;p&gt;&#8230;&lt;/p&gt;<br />
&lt;/article&gt;</div>
<p><a href="http://dev.w3.org/html5/spec/Overview.html#the-article-element" target="_blank">W3C Specification</a> (section 4.4.4)
</dd>
<dt>The &lt;section&gt; Element</dt>
<dd>The <code>&lt;section&gt;</code> element defines generic sections of a document, article or entire application. The section element is intended to provide semantics for a document and is not intended to be used as a container for styling purposes, in which case a <code>&lt;div&gt;</code> element should be used.</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;article&gt;<br />
&nbsp; &nbsp; &lt;header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Some Post&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;time pubdate&gt;<span class="nu0">2011</span><span class="nu0">-10</span><span class="nu0">-02</span>&lt;<span class="re0">/time&gt;&lt;/</span>p&gt;<br />
&nbsp; &nbsp; &lt;/header&gt;<br />
&nbsp; &nbsp; &lt;p&gt;This <span class="kw1">is</span> a simple example of the article element.&lt;/p&gt;<br />
&nbsp; &nbsp; &lt;p&gt;&#8230;&lt;/p&gt;<br />
&nbsp; &nbsp; &lt;section&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Comments&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;article&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;Posted by: Eric Feminella&lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;time&gt;<span class="nu0">2011</span><span class="nu0">-10</span><span class="nu0">-1</span>&lt;<span class="re0">/time&gt;&lt;/</span>p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;Nice post, simple enough!&lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/article&gt;<br />
&nbsp; &nbsp; &lt;/section&gt;<br />
&nbsp; &nbsp; &lt;section&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Categories&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;span&gt;&lt;a href=<span class="st0">&quot;/html5&quot;</span>&gt;HTML5&lt;<span class="re0">/a&gt;&lt;/</span>span&gt;<br />
&nbsp; &nbsp; &lt;/section&gt;<br />
&lt;/article&gt;</div>
<p><a href="http://dev.w3.org/html5/spec/Overview.html#the-section-element" target="_blank">W3C Specification</a> (section 4.4.2)
</dd>
<dt>The &lt;aside&gt; Element</dt>
<dd>
The <code>&lt;aside&gt;</code> element represents content which is relevant to, or supportive of it&#8217;s surrounding content, but is not required to convey the information set forth by the surrounding content. General examples could include a pull quote, a blog roll, a sidebar etc.</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;article&gt;<br />
&nbsp; &nbsp; &lt;header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Some Post&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;time pubdate&gt;<span class="nu0">2011</span><span class="nu0">-10</span><span class="nu0">-02</span>&lt;<span class="re0">/time&gt;&lt;/</span>p&gt;<br />
&nbsp; &nbsp; &lt;/header&gt;<br />
&nbsp; &nbsp; &lt;p&gt;This <span class="kw1">is</span> a simple example of the article element.&lt;/p&gt;<br />
&nbsp; &nbsp; &lt;p&gt;&#8230;&lt;/p&gt;<br />
&nbsp; &nbsp; &lt;section&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Comments&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;article&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;Posted by: Eric Feminella&lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;time&gt;<span class="nu0">2011</span><span class="nu0">-10</span><span class="nu0">-1</span>&lt;<span class="re0">/time&gt;&lt;/</span>p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;Nice post, simple enough!&lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/article&gt;<br />
&nbsp; &nbsp; &lt;/section&gt;<br />
&nbsp; &nbsp; &lt;aside&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&lt;h1&gt;Categories&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&lt;span&gt;&lt;a href=<span class="st0">&quot;/html5&quot;</span>&gt;HTML5&lt;<span class="re0">/a&gt;&lt;/</span>span&gt;<br />
&nbsp; &nbsp; &lt;/aside&gt;<br />
&nbsp; &nbsp; &lt;aside&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&lt;ul id=<span class="st0">&quot;tags&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=<span class="st0">&quot;semantics/&quot;</span>&gt;semantics&lt;<span class="re0">/a&gt;&lt;/</span>li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=<span class="st0">&quot;elements/&quot;</span>&gt;elements&lt;<span class="re0">/a&gt;&lt;/</span>li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&#8230;&lt;/li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&lt;/ul&gt;<br />
&nbsp; &nbsp; &lt;/aside&gt;<br />
&lt;/article&gt;</div>
<p><a href="http://dev.w3.org/html5/spec/Overview.html#the-aside-element" target="_blank">W3C Specification</a> (section 4.4.5)
</dd>
<dt>The &lt;footer&gt; Element</dt>
<dd>
As with the <code>&lt;header&gt;</code> element, the <code>&lt;footer&gt;</code> element is rather self explanatory in that it allows for defining content which is to be denoted as a footer of a page, or a footer within a section element for it&#8217;s nearest ancestor. A page can contain multiple <code>&lt;footer&gt;</code> elements, each unique to a particular section.</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;article&gt;<br />
&nbsp; &nbsp; &lt;header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Some Post&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;time pubdate&gt;<span class="nu0">2011</span><span class="nu0">-10</span><span class="nu0">-02</span>&lt;<span class="re0">/time&gt;&lt;/</span>p&gt;<br />
&nbsp; &nbsp; &lt;/header&gt;<br />
&nbsp; &nbsp; &lt;p&gt;This <span class="kw1">is</span> a simple example of the article element.&lt;/p&gt;<br />
&nbsp; &nbsp; &lt;p&gt;&#8230;&lt;/p&gt;<br />
&nbsp; &nbsp; &lt;section&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Comments&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;article&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;Posted by: Eric Feminella&lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;time&gt;<span class="nu0">2011</span><span class="nu0">-10</span><span class="nu0">-1</span>&lt;<span class="re0">/time&gt;&lt;/</span>p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;Nice post, simple enough!&lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/article&gt;<br />
&nbsp; &nbsp; &lt;/section&gt;<br />
&nbsp; &nbsp; &lt;aside&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&lt;h1&gt;Categories&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&lt;span&gt;&lt;a href=<span class="st0">&quot;/html5&quot;</span>&gt;HTML5&lt;<span class="re0">/a&gt;&lt;/</span>span&gt;<br />
&nbsp; &nbsp; &lt;/aside&gt;<br />
&nbsp; &nbsp; &lt;aside&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&lt;ul id=<span class="st0">&quot;tags&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=<span class="st0">&quot;semantics/&quot;</span>&gt;semantics&lt;<span class="re0">/a&gt;&lt;/</span>li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=<span class="st0">&quot;elements/&quot;</span>&gt;elements&lt;<span class="re0">/a&gt;&lt;/</span>li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&#8230;&lt;/li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp;&lt;/ul&gt;<br />
&nbsp; &nbsp; &lt;/aside&gt;<br />
&nbsp; &nbsp; &lt;footer&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;div <span class="kw2">class</span>=<span class="st0">&quot;g-plusone&quot;</span> data-annotation=<span class="st0">&quot;inline&quot;</span>&gt;&lt;/div&gt;<br />
&nbsp; &nbsp; &lt;/footer&gt;<br />
&lt;/article&gt;</div>
<p><a href="http://dev.w3.org/html5/spec/Overview.html#the-footer-element" target="_blank">W3C Specification</a> (section 4.4.9)
</dd>
</dl>
</div>
<div>
<h2>Putting it all Together</h2>
<p>The following example is comprised of each semantic element described above to form a complete, <a href="http://validator.w3.org/#validate_by_input" target="_blank">valid</a> HTML5 document:</p>
<div class="dean_ch" style="white-space: wrap;">
&lt;!doctype html&gt;<br />
&lt;html&gt;<br />
&nbsp; &nbsp; &lt;head&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;meta charset=<span class="st0">&quot;utf-8&quot;</span> /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;title&gt;HTML5 Semantic Structure Example&lt;/title&gt;<br />
&nbsp; &nbsp; &lt;/head&gt;<br />
&nbsp; &nbsp; &lt;body&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Some Blog&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h2&gt;Some Blog Description&lt;/h2&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;Last Modified: &lt;time&gt;<span class="nu0">2011</span><span class="nu0">-10</span><span class="nu0">-02</span>&lt;<span class="re0">/time&gt;&lt;/</span>p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;nav&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Navigation&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ul&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=<span class="st0">&quot;home.php&quot;</span>&gt;Home&lt;<span class="re0">/a&gt;&lt;/</span>li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=<span class="st0">&quot;about.php&quot;</span>&gt;About&lt;<span class="re0">/a&gt;&lt;/</span>li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=<span class="st0">&quot;contact.php&quot;</span>&gt;Contact&lt;<span class="re0">/a&gt;&lt;/</span>li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ul&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/nav&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;article&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Some Post&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;time pubdate&gt;<span class="nu0">2011</span><span class="nu0">-10</span><span class="nu0">-02</span>&lt;<span class="re0">/time&gt;&lt;/</span>p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;This <span class="kw1">is</span> a simple example of the article element.&lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;…&lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;section&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Comments&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;article&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;Posted by: Eric Feminella&lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;time&gt;<span class="nu0">2011</span><span class="nu0">-10</span><span class="nu0">-13</span>&lt;<span class="re0">/time&gt;&lt;/</span>p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/header&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;Nice post, simple enough!&lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/article&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/section&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;aside&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Categories&lt;/h1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;span&gt;&lt;a href=<span class="st0">&quot;/html5&quot;</span>&gt;HTML5&lt;<span class="re0">/a&gt;&lt;/</span>span&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/aside&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;aside&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ul id=<span class="st0">&quot;tags&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=<span class="st0">&quot;semantics/&quot;</span>&gt;semantics&lt;<span class="re0">/a&gt;&lt;/</span>li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;a href=<span class="st0">&quot;elements/&quot;</span>&gt;elements&lt;<span class="re0">/a&gt;&lt;/</span>li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&#8230;&lt;/li&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ul&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/aside&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;footer&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div <span class="kw2">class</span>=<span class="st0">&quot;g-plusone&quot;</span> data-annotation=<span class="st0">&quot;inline&quot;</span>&gt;&lt;/div&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/footer&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/article&gt;<br />
&nbsp; &nbsp; &lt;/body&gt;<br />
&lt;/html&gt;</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ericfeminella.com/blog/2011/10/19/html5-structural-elements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Circumventing Conditional Comparisons</title>
		<link>http://www.ericfeminella.com/blog/2011/10/14/circumventing-conditional-comparisons/</link>
		<comments>http://www.ericfeminella.com/blog/2011/10/14/circumventing-conditional-comparisons/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 23:36:37 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[APIs]]></category>
		<category><![CDATA[Code Review]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Object Oriented Design]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[conditional comparison]]></category>
		<category><![CDATA[equality operator]]></category>
		<category><![CDATA[identity operator]]></category>
		<category><![CDATA[javascript equality operator]]></category>
		<category><![CDATA[javascript identity operator]]></category>

		<guid isPermaLink="false">http://www.ericfeminella.com/blog/?p=2800</guid>
		<description><![CDATA[Often during the course of my day I come across code which evaluates the same conditional comparisons in multiple contexts. Understandably, this is rather typical of most software systems, and while it may only introduce a negligible amount of technical dept (in the form of redundancy) for smaller systems, that dept can grow considerably in [...]]]></description>
			<content:encoded><![CDATA[<p>Often during the course of my day I come across code which evaluates the same conditional comparisons in multiple contexts. Understandably, this is rather typical of most software systems, and while it may only introduce a negligible amount of technical dept (in the form of redundancy) for smaller systems, that dept can grow considerably in more complex, large scale applications. From a design perspective, this issue is applicable to nearly every language.</p>
<p>For example, consider a simple <code>Compass</code> class which defines just one public property, &#8220;direction&#8221; and, four constants representing each cardinal direction: North, East, South and West, respectively. In JavaScript, this could be defined simply as follows:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">var</span> Compass = <span class="kw2">function</span><span class="br0">&#40;</span>direction<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">direction</span> = direction;<br />
<span class="br0">&#125;</span><br />
Compass.<span class="me1">NORTH</span> = <span class="st0">&quot;North&quot;</span>;<br />
Compass.<span class="me1">EAST</span> &nbsp;= <span class="st0">&quot;East&quot;</span>;<br />
Compass.<span class="me1">SOUTH</span> = <span class="st0">&quot;South&quot;</span>;<br />
Compass.<span class="me1">WEST</span> &nbsp;= <span class="st0">&quot;West&quot;</span>;</div>
<p>Technically, there is nothing problematic with the above class signature; the defined constants certainly provide a much better design than conditional comparisons against literal strings throughout implementation code. That being said, this design does lead to redundancy as every instance of <code>Compass</code> which needs to evaluate the state of <code>direction</code> requires conditional comparisons. </p>
<p>For example, to test for <code>Compass.North</code>, typically, client code must be implemented as follows: </p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw1">if</span> <span class="br0">&#40;</span>compass.<span class="me1">direction</span> === Compass.<span class="me1">NORTH</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <br />
&nbsp; &nbsp; <span class="co1">//&#8230;</span><br />
<span class="br0">&#125;</span></div>
<p>Likewise, simular comparisons would need to be implemented for each cardinal direction. And, while this may seem trivial for a class as simple as the <code>Compass</code> example, it does become a maintenance issue for more complex implementations. </p>
<p>With this in mind, we can simplify client code by defining each state as a specific method of <code>Compass</code>. In doing so, we afford our code the benefit of exercising (unit testing) <code>Compass</code> exclusively. This alone improves maintainability while also simplifying client code which depends on <code>Compass</code>. As such, <code>Compass</code> could be refactored to:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">var</span> Compass = <span class="kw2">function</span><span class="br0">&#40;</span>direction<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">direction</span> = direction;<br />
<span class="br0">&#125;</span><br />
Compass.<span class="me1">prototype</span> = <span class="br0">&#123;</span><br />
&nbsp; &nbsp; isNorth: <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw1">this</span>.<span class="me1">direction</span> === Compass.<span class="me1">NORTH</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span>,<br />
&nbsp; &nbsp; isWest: <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw1">this</span>.<span class="me1">direction</span> === Compass.<span class="me1">WEST</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span>,<br />
&nbsp; &nbsp; isSouth: <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw1">this</span>.<span class="me1">direction</span> === Compass.<span class="me1">SOUTH</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span>,<br />
&nbsp; &nbsp; isEast: <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw1">this</span>.<span class="me1">direction</span> === Compass.<span class="me1">EAST</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>Based on the above implementation of <code>Compass</code>, the previous conditional comparison can be refactored as follows:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw1">if</span> <span class="br0">&#40;</span>compass.<span class="me1">isNorth</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <br />
&nbsp; &nbsp; <span class="co1">//&#8230;</span><br />
<span class="br0">&#125;</span></div>
<h3>Comparator API</h3>
<p>To simplify implementing conditional comparisons, I have provided a simple <code>Comparator</code> API that defines a single static method: <code>Comparator.each</code>, which allows for augmenting existing objects with comparison methods. <code>Comparator.each</code> can be invoked with three arguments as follows:</p>
<table class="api-doc-table" cellspacing="0">
<thead></thead>
<tbody>
<tr class="api-method">
<td>type
<td class="default"></td>
</tr>
<tr>
<td colspan="2" class="desc">The Class to which the comparison methods are to be added.</td>
</tr>
<tr class="api-method">
<td>property</td>
<td class="default"></td>
</tr>
<tr>
<td colspan="2" class="desc">The property against which the comparisons are to be made. If the property has not been defined it, too, will be added.</td>
</tr>
<tr class="api-method">
<td>values</td>
<td class="default"></td>
</tr>
<tr>
<td colspan="2" class="desc">An <code>Array</code> of constants where each value will be used to create a new comparison method (prefixed with &#8220;is&#8221;). If the constants specified are Strings, typically an <code>Array</code> containing each constant should suffice. For example, passing <code>[Foo.BAR]</code> where <code>BAR</code> equals &#8220;Bar&#8221; would result in an <code>isBar()</code> method being created. To specify custom comparison method names, an <code>Object</code> of name/value pairs can be used where each name defines the name of the method added and the value is the constant evaluated by the method. This is useful for constants which are not strings. For example, <code>{isIOS421: DeviceVersion.IOS_4_2_1}</code> where <code>IOS_4_2_1</code> equals 4.2.1 would result in an <code>isIOS421()</code> method being created.</td>
</tr>
</table>
<p>Taking the <code>Compass</code> example, the previous comparison methods could be augmented without the need to explicitly define them via <code>Comparator.each</code>:</p>
<div class="dean_ch" style="white-space: wrap;">
<span class="kw2">var</span> Compass = <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">this</span>.<span class="me1">direction</span> = direction;<br />
<span class="br0">&#125;</span><br />
Compass.<span class="me1">NORTH</span> = <span class="st0">&quot;North&quot;</span>;<br />
Compass.<span class="me1">EAST</span> &nbsp;= <span class="st0">&quot;East&quot;</span>;<br />
Compass.<span class="me1">SOUTH</span> = <span class="st0">&quot;South&quot;</span>;<br />
Compass.<span class="me1">WEST</span> &nbsp;= <span class="st0">&quot;West&quot;</span>;<br />
Comparator.<span class="me1">each</span><span class="br0">&#40;</span> Compass, <span class="st0">&quot;direction&quot;</span>, <span class="br0">&#91;</span>Compass.<span class="me1">NORTH</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Compass.<span class="me1">WEST</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Compass.<span class="me1">SOUTH</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Compass.<span class="me1">EAST</span><span class="br0">&#93;</span> <span class="br0">&#41;</span>;</div>
<p>The above results in the comparison methods <code>isNorth</code>, <code>isEast</code>, <code>isSouth</code> and <code>isWest</code> being added to the <code>Compass</code> type.</p>
<p><strong>Comparator</strong>: <span class="figure"><a href="http://code.ericfeminella.com/apis/javascript/comparator/js/comparator.js" target="_blank">source</a> | <a href="http://code.ericfeminella.com/apis/javascript/comparator/js/comparator-min.js" target="_blank">min</a> | <a href="http://code.ericfeminella.com/apis/javascript/comparator/tests/comparator-test.js" target="_blank">test</a> (<a href="http://code.ericfeminella.com/apis/javascript/comparator" target="_blank">run</a>)</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ericfeminella.com/blog/2011/10/14/circumventing-conditional-comparisons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

