git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
03d2680
)
Fix an issue with adding multiple event handlers and reattaching the global event...
author
Brandon Aaron
<brandon.aaron@gmail.com>
Sun, 22 Apr 2007 16:34:23 +0000
(16:34 +0000)
committer
Brandon Aaron
<brandon.aaron@gmail.com>
Sun, 22 Apr 2007 16:34:23 +0000
(16:34 +0000)
src/event/event.js
patch
|
blob
|
history
diff --git
a/src/event/event.js
b/src/event/event.js
index
61bd4e8
..
3834fd6
100644
(file)
--- a/
src/event/event.js
+++ b/
src/event/event.js
@@
-38,22
+38,19
@@
jQuery.event = {
// Init the element's event structure
if (!element.$events)
element.$events = {};
// Init the element's event structure
if (!element.$events)
element.$events = {};
-
- // Get the current list of functions bound to this event
- var handlers = element.$events[type];
-
- // Init the event handler queue
- if (!handlers)
- handlers = element.$events[type] = {};
-
- // Add the function to the element's handler list
- handlers[handler.guid] = handler;
- if (!element.$handle) {
+ if (!element.$handle)
element.$handle = function() {
jQuery.event.handle.apply(element, arguments);
};
element.$handle = function() {
jQuery.event.handle.apply(element, arguments);
};
+ // Get the current list of functions bound to this event
+ var handlers = element.$events[type];
+
+ // Init the event handler queue
+ if (!handlers) {
+ handlers = element.$events[type] = {};
+
// And bind the global event handler to the element
if (element.addEventListener)
element.addEventListener(type, element.$handle, false);
// And bind the global event handler to the element
if (element.addEventListener)
element.addEventListener(type, element.$handle, false);
@@
-61,6
+58,9
@@
jQuery.event = {
element.attachEvent("on" + type, element.$handle, false);
}
element.attachEvent("on" + type, element.$handle, false);
}
+ // Add the function to the element's handler list
+ handlers[handler.guid] = handler;
+
// Remember the function in a global list (for triggering)
if (!this.global[type])
this.global[type] = [];
// Remember the function in a global list (for triggering)
if (!this.global[type])
this.global[type] = [];
@@
-102,7
+102,7
@@
jQuery.event = {
element.removeEventListener(type, element.$handle, false);
else if (element.detachEvent)
element.detachEvent("on" + type, element.$handle, false);
element.removeEventListener(type, element.$handle, false);
else if (element.detachEvent)
element.detachEvent("on" + type, element.$handle, false);
- ret = element.$handle = null;
+ ret = null;
delete events[type];
}
}
delete events[type];
}
}
@@
-110,7
+110,7
@@
jQuery.event = {
// Remove the expando if it's no longer used
for ( ret in events ) break;
if ( !ret )
// Remove the expando if it's no longer used
for ( ret in events ) break;
if ( !ret )
- element.$events = null;
+ element.$handle = element.$events = null;
}
},
}
},