1 min read

IE8 is Gonna Rock

So maybe my title was a bit overdramatic. But in the announcement of IE8's features, one jumped out at me as a potentially game-changing feature.

http://www.microsoft.com/windows/products/winfamily/ie/ie8/readiness/DevelopersNew.htm#dom

Yes.

That's right.

"Selectors are a query language for searching and “selecting” tags (elements) within a webpage. They are most commonly seen in CSS to “select” a group of elements to which certain properties will be applied:

Selector{ 
   property: value;
   property2: value;
}

In Internet Explorer 7 there is no way of "executing" the selector independently of CSS. Internet Explorer 8’s implementation of the Selectors API is based on the W3C Working Draft: http://www.w3.org/TR/selectors-api/"

Yes. You read that correctly. To the extent of IE8's support for CSS2.1 (which should be relatively complete, according to their announcement), it will be possible to use the standards-compliant querySelector and querySelectorAll in IE to get collections of elements at native speed. This means fast class-name lookup, fast attribute lookup, and much much more.

Here's a lame example of its use from an IE8 whitepaper:

function doValidation ()  { 
// Retrieve the required elements by using Selectors 
   // Selects all the form fields with 'required' classes 
var reqs = document.querySelectorAll(".required"); 
   // Set the flag to false by default 
var missingRequiredField = false; 
// Validate that the form data is not empty 
for (var i = 0; i < reqs.length; i++)  { 
if (reqs[i].value == "") 
         missingRequiredField = true; 
   }

Yep. It is what it looks like. Finally, the days of slow IE selectors may be coming to an end. And finally, one where MS is ahead of the curve (in fact, a lot of the IE8 improvements are pretty neat and forward-looking; I recommend taking a look at it)