AnitaTang / js-hotkeys

Automatically exported from code.google.com/p/js-hotkeys
0 stars 0 forks source link

Broken with jQuery 1.4.3 - jQuery.fn.bind collision #91

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use jQuery Hot Keys with jQuery version 1.4.3.
   You'll see a script error automatically.

Please provide any additional information below.
Newly added overloaded bind() method from jQuery 1.4.3 is *probably* colliding 
with the jQuery Hot Keys' overloaded method defined at Line #92 in jQuery 
hotkeys 0.7.9.

Original issue reported on code.google.com by soel...@gmail.com on 18 Oct 2010 at 7:25

GoogleCodeExporter commented 8 years ago
Microsoft JScript runtime error: 'combi' is null or not an object

In IE 8

Original comment by mcoo...@techie.com on 21 Oct 2010 at 5:41

GoogleCodeExporter commented 8 years ago
i confirm, plugin is producing an error.
please, fix this as soon as possible :)

Original comment by serge....@gmail.com on 22 Oct 2010 at 11:12

GoogleCodeExporter commented 8 years ago
As far as I can see, the fix is as simple as changing the check to (adding data 
== null):

var handle = type.match(hotkeys.override);
if (data == null || jQuery.isFunction(data) || !handle){

Original comment by emond.pa...@gmail.com on 25 Oct 2010 at 2:11

GoogleCodeExporter commented 8 years ago
Actually, addding data == null is not enough in some cases. This test does work 
for me :

var handle = type.match(hotkeys.override);
if (arguments.length == 2 || (arguments.length == 3 && data == null) || 
!handle){

There is also an issue when binding events to window.document (global hotkeys). 
jQuery 1.4.3 does not allow to use .attr() on the window.document object 
anymore, so I just replaced all the uses of attr (setter and getter) with their 
.data() equivalent.

I attached the fixed plugin (all modified lines are commented with //PATCH).

Original comment by clement.denis on 25 Oct 2010 at 3:35

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks clement - that's great.

Original comment by fergus.g...@gmail.com on 6 Nov 2010 at 8:22

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Thanks a lot for the file clement..

Original comment by sagar20...@gmail.com on 22 Nov 2010 at 11:26

GoogleCodeExporter commented 8 years ago
yes, thank you

Original comment by serge....@gmail.com on 22 Nov 2010 at 12:38

GoogleCodeExporter commented 8 years ago
Hi Denis,

Tried the new file and am getting an out of stack space.
 At line 89  return  this.__unbind__(type, fn);

throws error: Out of stack space

When using Jquery 1.4.4

Original comment by mcoo...@techie.com on 24 Nov 2010 at 3:00

GoogleCodeExporter commented 8 years ago
Did not try it yet with jQuery 1.4.4, but I'll be upgrading in the next few 
days. I'll try to fix the unbind issue too.

BTY, from the Jquery blog 
(http://blog.jquery.com/2010/11/23/team-spotlight-the-jquery-bug-triage-team/) 
: "We determined that a regression was introduced in 1.4.3 which limited the 
use of attr() to nodeType 1 DOM element nodes"
So my workaround with the .data() methods instead of .attr() is not needed 
anymore ... but it looks cleaner to me (does not modify the dom directly).

Original comment by clement.denis on 24 Nov 2010 at 3:25

GoogleCodeExporter commented 8 years ago
Seeing as this jQuery plugin is based on 
http://www.openjs.com/scripts/events/keyboard_shortcuts/ I downloaded that 
library and rewrote my code to use that instead.

As it is completely separate from jQuery it doesn't mess with any of the jQuery 
internals and the file size is even smaller as the jQuery one as well!

Original comment by anotherhero on 6 Dec 2010 at 1:13

GoogleCodeExporter commented 8 years ago
Thanks

Original comment by AntonGor...@gmail.com on 17 Dec 2010 at 9:40

GoogleCodeExporter commented 8 years ago
I got this[0] is undefined in this line :

selectorId = ((this.prevObject && this.prevObject.query) || (this[0].id && 
this[0].id) || this[0]).toString();

Original comment by x.nd...@gmail.com on 19 Mar 2011 at 10:06

GoogleCodeExporter commented 8 years ago
@x.nd...@gmail.com

change (this[0].id && this[0].id) to (this[0] && this[0].id)

Original comment by katow...@gmail.com on 1 Aug 2011 at 7:19