lynaghk/singult — pull request #20 by sfnelson (2013-07-15 04:32:39+00:00)
Title: Made unify's enter/exit functions more usable

* 'enter' is called when a datum is added the first time.
Given a datum, it should return a dom node that will be appended/inserted in the appropriate place.
Previously enter was expected to insert/append the node manually, but was not passed the container.
This is consistent with the behaviour of render's enter.
* 'exit' is called when a datum is removed (actual remove, not just update).
Given the dom node and the datum, exit may clean up any structures created by enter/update but is
not required to do anything at all. After exit returns the dom node will be removed from its container.
Previously exit was expected to remove the dom node but was not provided with the datum. Relaxing the
requirement that exit remove the node is more symmetric with enter's behaviour.

I want to use enter/exit to attach/detach event handlers to the dom. Currently I can't specify a custom enter fn because I don't have access to the parent element to attach the node to.

I believe that these changes don't affect existing code as dom inserts/removes are idempotent and the extra argument to exit will be safely ignored by existing code, but you might want to verify that for yourself. Happy to change/discuss this patch.