Side navigation
#7852 closed bug (wontfix)
Opened December 28, 2010 10:40AM UTC
Closed December 29, 2010 02:24AM UTC
Problem of Adding same Event listener Hanlder
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.6 |
| Component: | unfiled | Version: | 1.4.2 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
jQuery 1.4.2 line 1663-1664:
// Add the function to the element's handler list
handlers.push( handleObj );
to
// Add the function to the element's handler list
var handle_exists = false;
for (var i = 0; i < handlers.length; ++i) {
if (handlers[i].guid == handleObj.guid) {
handle_exists = true;
}
}
if (handle_exists == false) {
handlers.push( handleObj );
}
I guess, This jQuery(>=1.4.2)'s problem is caused by changing type of handlers object to array, line 1639.
The reason to post is I want to use jquery.hotkey.js with lastest jQuery.
But I faced the problem with jQuery over 1.4.2 version.
sample problem code:
<!DOCTYPE html> <html> <head> <script src="./jquery-1.4.2.js"></script> <script src="./jquery.hotkeys-0.7.9.js"></script> <script> $(function() { function output() { console.log(this); } $(document.body).bind('keydown', 'j', output); $(document.body).bind('keydown', 'k', output); }); </script> </head> <body></body> </html>Opening this and pressing 'j' or 'k', JS console gets document.body three times.
To suspend code to the last post one, JS console gets once.