Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

remove the wrap because it should be no more necessary #2424

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Member

kentaromiura commented Sep 2, 2012

cpojer say that is safe to remove everything. so blame him if is not.

Cristian Carlesso remove the wrap because it should be no more necessary
cpojer say that is safe to remove everything. so blame him if is not.
756bbaf
Owner

arian commented Sep 5, 2012

I think this would be good, so it still removes the unload which is used for gc:

diff --git a/Source/Element/Element.js b/Source/Element/Element.js
index db38211..0197a1c 100644
--- a/Source/Element/Element.js
+++ b/Source/Element/Element.js
@@ -898,13 +898,7 @@ Element.implement({
 [Element, Window, Document].invoke('implement', {

    addListener: function(type, fn){
-       if (type == 'unload'){
-           var old = fn, self = this;
-           fn = function(){
-               self.removeListener('unload', fn);
-               old();
-           };
-       } else if (window.attachEvent && !window.addEventListener){
+       if (window.attachEvent && !window.addEventListener){
            collected[Slick.uidOf(this)] = this;
        }
        if (this.addEventListener) this.addEventListener(type, fn, !!arguments[2]);
@@ -939,10 +933,14 @@ Element.implement({
 });

 /*<ltIE9>*/
-if (window.attachEvent && !window.addEventListener) window.addListener('unload', function(){
-   Object.each(collected, clean);
-   if (window.CollectGarbage) CollectGarbage();
-});
+if (window.attachEvent && !window.addEventListener){
+   var gc = function(){
+       Object.each(collected, clean);
+       if (window.CollectGarbage) CollectGarbage();
+       window.removeListener('unload', gc);
+   }
+   window.addListener('unload', gc);
+}
 /*</ltIE9>*/

 Element.Properties = {};

This way unload will be collected too, which is good probably.

Owner

arian commented Sep 5, 2012

Closing in favor of d54312c

@arian arian closed this Sep 5, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment