MooTools 1.2 Beta 1
The first beta of MooTools 1.2 was released yesterday, so, today, instead of studying, I decided to give it a go, because that’s just how responsible I am. Here are my first impressions …
While the API has changed quite a bit, there’s a compatibility mode, which adds just a couple of kilobytes to the library’s size.
I usually grab the entire codebase anyway, which allows me to try out the stuff I’m not familiar with yet without hassle. The bit of extra payload this introduces doesn’t matter that much once Packer and gzip are done with it.
Consequently, I thought it wouldn’t hurt to add the compatibility layer as well, especially since this wouldn’t break any of my existing code, which I would then gradually upgrade. Obviously, I was wrong. The Request class, for instance, which replaces Ajax, doesn’t pass the resulting XML document to your onComplete handler anymore—you have to use this.response.xml. I’m not sure if that’s the intended behavior. The docs, pretty as they are, are a bit scarce at times, so I just deduced it from the previous version’s code; it seemed logical though.
Most likely, there are a couple more of these tiny oversights in the compatibility layer, which the developers will probably fix by the final release. Nonetheless, I swiftly decided to leave the whole thing out and just start porting everything. It’s better in the long run.
Most of the new stuff is an improvement. The Hash class is convenient, but if I were them, I’d have kept some of the functions that it renders trivial. For instance, to get an element’s inner text, you now have to write
var text = element.get('text');
instead of the familiar
var text = element.getText();
The same goes for inner HTML, element values and tag names. Another thing they’ve gotten rid of is setOpacity(), which I’d already complained about. Incidentally, I found out I probably should’ve used implement() instead of extend() in that code, so if it doesn’t work anymore, that’s why.
If you don’t like the standard
var textNode = document.createTextNode('foo');
they’ve now got the rather beautiful
var textNode = new TextNode('foo');
It’d be nice, however, if it actually worked in Internet Explorer 7. I couldn’t, for the life of me, figure out what went wrong when I tried it.
Speaking of IE shortcomings, I had some trouble with Element’s getCoordinates() function returning the wrong values. I’m not sure if that already happened with version 1.1, but it’s forcing me to disable the search balloon when IE users click on the magnifying glass.
It’s no secret, however, that this site isn’t very IE-friendly to begin with. I try to hack in some fixes when necessary, but I can only recommend using a Gecko browser if you want to experience it to the fullest.
Now, while I seemingly only list bugs and controversial design moves, I’m actually pretty pleased with this beta and you’re currently looking at pages that make fairly heavy use of it. I can’t speak for some of the more advanced features, such as the accordion that made MooTools famous, but I’d say it’s worth taking the risk of using it in a production environment—that is, if you know enough JavaScript to go digging through the code while they prepare the docs.