Skip to content
Permalink
Browse files

Make sure that we don't bind the onunload event in Opera.

  • Loading branch information
jeresig committed Dec 19, 2009
1 parent 3fd62ea commit 1feb92afb42d5213e2705290761779260bbd1fa4
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/event.js
@@ -882,7 +882,7 @@ jQuery.each( ("blur focus load resize scroll unload click dblclick " +
// Window isn't included so as not to unbind existing unload events
// More info:
// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
if ( window.attachEvent ) {
if ( window.attachEvent && !window.addEventListener ) {
window.attachEvent("onunload", function() {
for ( var id in jQuery.cache ) {
if ( jQuery.cache[ id ].handle ) {

8 comments on commit 1feb92a

@jeresig

This comment has been minimized.

Copy link
Member Author

jeresig replied Dec 19, 2009

Forgot to thank kangax for the recommendation!

@NV

This comment has been minimized.

Copy link

NV replied Dec 20, 2009

Just curious, why not

if ( window.attachEvent && /*@cc_on 1 */ ) {

?

@NV

This comment has been minimized.

Copy link

NV replied Dec 20, 2009

Oops, I forgot "@"
if ( window.attachEvent && /@cc_on 1 @/ ) {

@kangax

This comment has been minimized.

Copy link

kangax replied Dec 21, 2009

@NV
Or just — if (/*@cc_on ! @*/0). I guess removal of conditional comments is to cater to Closure Compiler (which strips them). if (window.attachEvent && !window.addEventListener) is a decent inference, but might fail when someone defines custom addEventListener on window (as, for example, MSDN demonstrates — http://msdn.microsoft.com/en-us/library/dd229916%28VS.85%29.aspx). The chance of someone following MSDN example is too big, as for my taste, so I'd rather go with something similar to what Garrett does in APE — var isMaybeLeak/*@cc_on=(@_jscript_version<5.7)@*/ (http://github.com/GarrettS/ape-javascript-library/blob/master/src/EventPublisher.js)

@NV

This comment has been minimized.

Copy link

NV replied Dec 21, 2009

kangax, you are right about if (/*@cc_on ! @*/0). My code doesn't even work.

isMaybeLeak/*@cc_on=(@_jscript_version<5.7)@*/ looks much bulletproof.

@dmethvin

This comment has been minimized.

Copy link
Member

dmethvin replied Dec 21, 2009

The Closure compiler strips out comments, so I think the goal was to eliminate conditional comments completely from jQuery so that it is easy to build the compressed version.

@DBJDBJ

This comment has been minimized.

Copy link

DBJDBJ replied Dec 21, 2009

The just do not use the "closure compiler", I guess ?
Is Microsoft Ajax Minifier any good?
http://stephenwalther.com/blog/archive/2009/10/16/using-the-new-microsoft-ajax-minifier.aspx

@dmethvin

This comment has been minimized.

Copy link
Member

dmethvin replied Dec 22, 2009

The MS tool also strips out conditional comments, it seems:

http://ajaxian.com/archives/microsoft-ajax-minifier-vs-yui-compressor

Please sign in to comment.
You can’t perform that action at this time.