shama / on-load

On load/unload events for DOM elements using a MutationObserver
113 stars 19 forks source link

Pass el to onload callback #7

Closed timwis closed 8 years ago

timwis commented 8 years ago

In bel, @yoshuawuyts suggested:

Might be worth considering to pass the enclosing element as the first argument to the callback for onload so that any stuff like d3 can just attach itself to the node instead of having to do some odd hoop jumping to find the node it should append itself to.

I see you incorporated that - thanks! Makes things a lot easier. I wonder, though, whether it fits better in on-load? So that both onload(el, on) and <div onload=${on}> callbacks have the same signature? If so, I'm happy to throw the PR together, but wanted to ask whether there was a reason behind it first.

Thanks again!

shama commented 8 years ago

The main reason is so I don't have to keep a reference to the element around (as we don't get the old element onunload). But agree having the same signature would be nice and would take a patch for it. Thanks!