uzairfarooq / arrive

Watch for DOM elements creation and removal
MIT License
872 stars 99 forks source link

Issue with binding to callback #58

Closed patrickklick closed 7 years ago

patrickklick commented 7 years ago

When I bind to the callback function, the "this" variable isn't the element, its the window.

ie:

document.arrive(".my_class", function (item) {
   console.log(this, item);
}.bind(null, myItem))

The this variable is returned as the window object. Can this be fixed?

uzairfarooq commented 7 years ago

I think the first argument passed to bind always overrides this. In case it's null, this becomes window. Check out the js fiddle https://jsfiddle.net/1xd0rh45/