Hacker News new | comments | show | ask | jobs | submit login

This is very cool. I've been wanting an alternative for Raphael in projects that don't require old IE support because of some compromises Raphael does in order to support VML.

I am a bit worried that I can't find a way of changing multiple elements at once, in d3 for example I'd do...

    d3.selectAll("rect").attr("fill", "red");
In Raphael I'd do...

    var set = paper.set(//insert rects here);
    set.attr({"fill": "red});
But in Bonsai I'd do...

    var set = [//insert rects here];
So it doesn't abstract the iteration for you.

Personally, I never did like things abstracting the iteration for me. In Javascript, I tend to favor explicit loops over huge chains of method calls, or visually confusing abstracting like the Raphael example. Just looking at that Raphael example, I'd have to actually think about the code to understand what it does right off the bat (shocker, I know, but I think you get my point). I actually think that the Bonsai example there is the most straight forward and flexible. Of course, this is all just opinion.

When working with DOM elements (SVG elements are also part of the DOM) it get messy pretty quickly. Think of it as syntactic sugar, because you can always opt for using standard arrays instead of using Raphael sets...

    var rects = [//insert rects here]
       rect.attr({fill: "red"});

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact