Bug fix updates for Bluff and JS.Class

First off, let me say that the response to the release of Bluff over the last couple of weeks has been astonishing, due in no small part to a helpful link from John Gruber. Thanks to everyone who’s reported bugs and suggested features; some of these have now been fixed but others will need to wait to be integrated into Gruff, which I now have commit access to (thank you, Geoff!).

I’ve just put out a bug fix update (version 0.3.4.1) that fixes various text rendering problems, and fixes a bug with zero-value data points in pie charts. The text rendering changes mean that you should no longer need to explicitly clear() a canvas before redrawing it, and text layout should behave a little better if the graph is moved by dynamic elements or text resizing. Other bugs that are present in Gruff as well will need to wait for a 0.3.5 release of both projects to be fixed; I’d like to keep Bluff as consistent with Gruff as I can for the time being. To grab the update, head on over to the Bluff site.

Secondly, I’ve also put out new releases of the 1.6.x and 2.0.x branches of JS.Class. Both releases feature some changes to the forEach methods of various Enumerable classes to stop the loop visiting nodes that are removed during the loop’s execution; a minor fix that may fix a few edge cases here and there. The new 2.0.x release fixes a bug that prevents you from storing references to callSuper in order to use it asynchronously. To illustrate, here’s the method in Ojay that showed up the bug:

    _handleSetPage: function(page) {
        if (this.pageLoaded(page)) return this.callSuper();
        var _super = this.method('callSuper');
        this.setState('REQUESTING');
        this.loadPage(page, function() {
            this.setState('READY');
            _super();
        }, this);
    }

This is in AjaxPaginator, a subclass of Paginator that loads content via Ajax. When a request to change page is made, it needs to ensure the page is actually loaded before performing the change using callSuper(), and the Ajax call means it needs to callSuper() after the original method call has returned. JS.Class had a bug that messed up the call stack index so the wrong method would be called, and this is now fixed.

To grab 2.0.2 (or 1.6.2 if you’re still using the legacy branch) hit up the JS.Class site. Any bug reports are, as ever, gratefully received.

If you’ve enjoyed this article, you might enjoy my recently published book JavaScript Testing Recipes. It’s full of simple techniques for writing modular, maintainable JavaScript apps in the browser and on the server.