ded / bonzo

library agnostic, extensible DOM utility
Other
1.32k stars 137 forks source link

bean integration for remove() #60

Closed rvagg closed 12 years ago

rvagg commented 12 years ago

A pull request for discussion purposes.

Continuing on from the Ender inter-module communication issue, 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?