ded/bonzo — pull request #60 by rvagg (2011-12-30 05:12:34+00:00)
Title: bean integration for remove()

A pull request for discussion purposes.

Continuing on from the Ender [inter-module communication issue](https://github.com/ender-js/Ender/issues/87), specifically where `bonzo.remove()` can leave you with Bean event handlers still attached so you don't have a proper clean-up.

The approach I've taken here is to create an extension / hooks / callbacks mechanism for Bonzo in the form of `bonzo._extend(type, fn)`. Where `type` is just `'remove'` at the moment but could be easily expanded to other extension points. I've shifted the existing `clearData()` into the extension list and then in the Ender bridge I've lazily detected Bean and if it exists I put in a call to `bean.remove(el)` in the extension list as well so Bean gets to clean up each time an element is removed from the DOM by Bonzo.

What think you?