Categories
Computers Etc Family

Daddy’s Little Hacker

hacking
hacking

The training is slowly progressing. Today email, tomorrow SQL and JavaScript.

Advertisements
Categories
Computers

A SCons Scanner for Dojo

Bjorn worked up a pretty sweet scanner for SCons that understands dojo.require statements. If you’re using SCons and Dojo, definitely take a peek.

Categories
Computers

Tracking Dojo using Git

Lately, I’ve been using Git as my source code management tool of choice, and I’ve especially come to love the Subversion integration provided by the git-svn command. It turns out that Git is an excellent façade on top of Subversion, providing a bunch of features I really enjoy: things like local commits, the ability to reorder commits before sending them upstream, and of course the fantastic branch and merge support for my little local experiments.

One of the projects I track using git-svn is Dojo. Tracking Dojo is a bit tricky as we use a non-standard Subversion repository layout, with each of the five main components of the overall toolkit having it’s own trunk, branches, tags triad, but release tags and most branches are actually handled in tags and branches directories located off the root of the repo. So, there are tags and branches local to each subproject and then there are overarching tags and branches that apply to all five sub-projects at once. It can get a bit confusing.

Anyway, you don’t have to deal with it. I’m putting my Git mirror of Dojo up on github for anyone to fork and enjoy. The mirror is currently updated when I feel like it, but I should have some scripts in place to update it every hour or so. The mirror itself is broken up much like the Subversion repository with one Git repository per sub-project in Dojo, and the bigger Dojo project which knits them all together using git submodules.

If you find this handy, do let me know, or just fork the project on github.

Update:

freelock on the #dojo channel on freenode did something similar but took it quite a bit futher. He found a way to pull all of the dojo subprojects into one git repo, and keep up to date with the overarching branches and tags. I definitely recommend taking a look at his approach if you find this whole thing interesting.

Categories
Computers

Chrome: Google’s New Browser

Google’s new Chrome web browser was released in beta today. So far, I like it quite a bit. It’s fast, the process-per-tab architecture really makes sense, and the awesome little comic book explaining it is brilliantly done. On Vista, the use of the aero glass is a really nice touch and I think the tabs on top really make sense.

I tried to test out the new v8 JavaScript engine it uses, but the SunSpider JS benchmark appears to be getting slammed at the moment. I wonder why… :)

Now it just remains to be seen if this can get any market share and how everyone reacts to it. So far, I give it a thumbs up.

Categories
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.