2 ms·
Thanks for the comment. I considered that, but I was thinking it makes things a little cleaner/easier to maintain by using Gator objects. Only one object inst
by craigc 14y ago
Thanks for the comment. I considered that, but I was thinking it makes things a little cleaner/easier to maintain by using Gator objects. Only one object instance is created per element. Also it allows for chaining methods.
- crescentfresh 14y ago> Only one object instance is created per element I think the point may be "Gator.on()" wouldn't need instances of anything allocated. But then you lose chaining.
- strager 14y agoI see. Still, your approach leaks memory as it maintains references to nodes which may otherwise be GC'able. Have you considered `WeakMap` for caching (where supported)?
- craigc 14y agoThat's a good point. I probably will add some sort of destroy method. I figure in most cases with delegation you are referencing an element that is not likely to be removed (such as document), but I probably should add a way to clean up stale objects. As for WeakMap, I wasn't even aware of that, looks awesome.