Apr 13

Before moving to YUI about a year ago, I was using Mochikit as my primary JS library. As advertised, Mochikit happens to be one of the most pythonic javascript libraries ever. One of the sweetest parts of Mochikit IMO has been Mochikit.DOM. This is something which I’ve always missed with YUI. innerHTML is fast, but icky and it feels a little inelegant. So, I ended up writing something like Mochikit.DOM for YUI while writing Tagz. Thought it might be useful to others as well. So, here’s the mercurial repo with the code.

The utils.js file contains some utility functions like forEach, map, filter, partial. The only function from utils.js used in dombuilder.js is partial, so you might want to add it to dombuilder.js to remove the dependence on utils.js.

Here’s an obligatory trivial example (included in the repo).

6 Responses to “A Mochikit style Dombuilder for YUI”

  1. Dav Glass Says:

    This is nice, how about moving the source to GitHub and adding it as a module to the yui2 project?
    http://github.com/yui/yui2

    See here about contributing:
    http://yuilibrary.com/contrib/

    I think it would make a nice addition to YUI :D

    Dav

  2. Writing HTML From JavaScript at 925 HTML Says:

    [...] fed up with either alternative and decide to create a new API for writing markup in JavaScript: Jeethu: “One of the sweetest parts of Mochikit IMO has been Mochikit.DOM. This is something which [...]

  3. Andrew Warner Says:

    This reminds me of some dom builder code I lifted from the original del.ici.ous site before it was overhauled by yahoo.
    The implementation is almost the same except it wasn’t encapsulated in a single object, but had some shortcut functions:
    $DIV ({style:{margin:’2px’}},
    $SPAN({style:{color:’white’,'background-color’:'#aa0011′,padding:’2px’}}, ‘You entered: ‘+s)
    )

  4. Jeethu Says:

    @Dav, I have absolutely no experience with git (Worked almost exclusively on mercurial and before that darcs), I’ve forked the repo on github and am learning the basics git, once I’m done with that, I’ll make a YUI module and submit a pull request.

  5. In the Wild for April 23, 2009 » Yahoo! User Interface Blog Says:

    [...] and methods exposed by the current API.” Check out the full article/tutorial on Carousel here.Jeethu Rao, “A Mochikit-style Dombuilder for YUI”: Writes Jeethu: “Before moving to YUI about a year ago, I was using Mochikit as my primary JS [...]

  6. In the Wild for April 23, 2009 | rapid-DEV.net Says:

    [...] Jeethu Rao, “A Mochikit-style Dombuilder for YUI”: Writes Jeethu: “Before moving to YUI about a year ago, I was using Mochikit as my primary JS library. As advertised, Mochikit happens to be one of the most pythonic javascript libraries ever. One of the sweetest parts of Mochikit IMO has been Mochikit.DOM. This is something which I’ve always missed with YUI. innerHTML is fast, but icky and it feels a little inelegant. So, I ended up writing something like Mochikit.DOM for YUI while writing Tagz. Thought it might be useful to others as well. So, here’s the mercurial repo with the code.” Check out the full blog post here. (Original source.) [...]

Leave a Reply