Computers Work

Yay for querySelectorAll. Boo for StaticNodeList.

In the coming months, all of the major browser vendors are going to implement a new API called querySelectorAll, which allows us web developers to query a document for elements matching a CSS3 selector and quickly get back a list of matching nodes. This is really fantastic news and should help to speed up one of the more common things we do in web apps.

We have basic support for the API in the latest Firefox 3.1 nightlies, IE8 beta 2, and WebKit, and Dojo has basic support in trunk for using querySelectorAll to drive dojo.query if itís available, so I thought Iíd try it out and see what happens.

Well, things Ö mostly Ö work. The selection stuff is great, but Dojo does one rather nice thing with the dojo.query interface: it returns an Array object thatís been decorated with the JS 1.7 array methods if theyíre not natively available, plus some other Dojo-specific things, like connect and style and so forth, to make running operations against the result set easy. For some reason, a number of these methods were broken.

I did some digging and it turns out that the breakage is happening because the querySelectorAll return is not an Array or a subclass of an Array, but a new thing called a StaticNodeList. It looks mostly like an array and works like an array, but it doesnít have any of the new array methods (at least on Firefox 3.1 and IE8 beta 2) and as itís not an array, it fails an instanceof check. This means code like this:

var spans = document.querySelectorAll("span");
var divs = document.querySelectorAll("div");
var both = spans.concat(divs); // fails, no concat method

just plain doesn’t work. JS devs already have this array-ish problem with the return from document.getElementsByTagName and the arguments object available inside functions. From looking at the spec for the StaticNodeList, I cannot for the life of me see why this isn’t just a plain array with the standard array methods on it. It’s a static collection, so treating it just like an array should be fine, no?

If anyone can shed light on why the returned value from querySelectorAll is not just a plain JS array, Iíd love to hear it.

Etc Work

Working From Home

Mandy’s always looking out for tips on how to make working from home work out for both of us and she found a great article with some tips for making it work.

For me, the most important things are:

  1. Having a routine with a clear separation between work and home,
  2. Having a set space in the house that is “the office” and
  3. Taking breaks, especially getting out of “the office” for lunch

If you work from home, what works for you?


A hidden feature in Bloglines beta

Lots of folks know about the hotkey support in Bloglines. You can hit “j” to move to the next item and “k” to move to the previous one. One item we’re trying out in the beta is a double-tap on “j” when you reach the end of a feed or folder. When you get to the last item, hit “j” once like you want to move to the next item and then hit it again to tell us, yes really do it. The next feed or folder (depending on what’s currently selected) will open up and you’ll be taken to the first item. Single-key reading ftw!


Thanks Tony!

Tony Morgan has a nice writeup on why he uses Bloglines. I just wanted to say thanks for the positive words. :)  3Pane view + iframe view really does change things quite a bit. We use it all the time internally.



Have an itch to chat with Bloglines engineers? You can usually find some of us on #bloglines on the FreeNode IRC servers. If you come join us, I’m blowery.