Why events aren't detached on unload?

瀏覽次數:59 次
跳到第一則未讀訊息

Daniel Steigerwald

未讀,
2010年10月28日 上午8:43:532010/10/28
收件者:Closure Library Discuss
Was DOM evens deregistration considered as antipattern? Or does Google
Closure use another approach? Or is detaching deferred to the user?
Or ..?
Thanx for answer.

Shawn Brenneman

未讀,
2010年10月29日 凌晨1:22:082010/10/29
收件者:closure-lib...@googlegroups.com
The library doesn't automatically unregister the listeners on page
unload. It's easy to add your own listener for the window unload event
and have it call goog.events.removeAll(). The events system is
believed to be reasonably resistant to memory leaks, but explicitly
removing all event handlers doesn't hurt.

Shawn

Daniel Steigerwald

未讀,
2010年10月29日 凌晨4:49:422010/10/29
收件者:Closure Library Discuss
Thank you for your answer. So, closure does not leak, even when it
does not automatically remove events at unload.
So every other js library does pointless unload removing? Funny ;)
The potential problem with unload registration can be, than u can use
reliably only once. Two unloads, first would remove second :)

d.
回覆所有人
回覆作者
轉寄
0 則新訊息