shama / on-load

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

Use Object.keys().length to test for watchers #9

Closed timwis closed 8 years ago

timwis commented 8 years ago

Presently, watch.length is always undefined because objects don't have a length property, so the for loop that follows gets called even when nothing is being watched. Object.keys() gets an array of the object's keys, which provides the length property we're after. Browser support is IE9+.