Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

saving a ref in order to remove the unload method #2423

Merged
merged 2 commits into from

2 participants

@kentaromiura
Collaborator

saving a ref in order to remove the unload method
add some test

Cristian Carlesso saving a ref in order to remove the unload method
saving a ref in order to remove the unload method
add some test
a71e9f9
Source/Element/Element.js
@@ -913,6 +913,11 @@ Element.implement({
},
removeListener: function(type, fn){
+ if (fn.$ref){
@arian Owner
arian added a note

if (type == 'unload' && fn.$ref){

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Cristian Carlesso adding a further check
adding a further check
b0de803
@arian arian merged commit 3b0388b into from
@arian arian referenced this pull request from a commit in arian/mootools-core
@arian arian Better fix for #2296 and #2423 - doesn't wrap onunload functions in a…
…ddListener anymore.
d54312c
@kentaromiura kentaromiura referenced this pull request from a commit in kentaromiura/mootools-core
@arian arian Better fix for #2296 and #2423 - doesn't wrap onunload functions in a…
…ddListener anymore.
f3ce01b
@arian arian referenced this pull request from a commit in ibolmo/mootools-core
@arian arian Better fix for #2296 and #2423 - doesn't wrap onunload functions in a…
…ddListener anymore.
4781d33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 2, 2012
  1. saving a ref in order to remove the unload method

    Cristian Carlesso authored
    saving a ref in order to remove the unload method
    add some test
  2. adding a further check

    Cristian Carlesso authored
    adding a further check
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 1 deletion.
  1. +6 −1 Source/Element/Element.js
  2. +9 −0 Specs/1.4client/Element/Element.js
View
7 Source/Element/Element.js
@@ -900,7 +900,7 @@ Element.implement({
addListener: function(type, fn){
if (type == 'unload'){
var old = fn, self = this;
- fn = function(){
+ old.$ref = fn = function(){
self.removeListener('unload', fn);
old();
};
@@ -913,6 +913,11 @@ Element.implement({
},
removeListener: function(type, fn){
+ if (type == 'unload' && fn.$ref){
+ var old = fn;
+ fn = fn.$ref;
+ delete old.$ref;
+ }
if (this.removeEventListener) this.removeEventListener(type, fn, !!arguments[2]);
else this.detachEvent('on' + type, fn);
return this;
View
9 Specs/1.4client/Element/Element.js
@@ -10,6 +10,15 @@ describe('Element', function(){
describe('Element.getProperty', function(){
+ it('should remove the onunload method', function(){
+ var text;
+ var handler = function(){ text = 'nope'; };
+ window.addEvent('unload', handler);
+ window.removeEvent('unload', handler);
+ window.fireEvent('unload');
+ expect(text).toBe(undefined);
+ });
+
it('should get the attrubte of a form when the form has an input with as ID the attribute name', function(){
var div = new Element('div');
div.innerHTML = '<form action="s"><input id="action"></form>';
Something went wrong with that request. Please try again.