Reputation: 1086
I'm working on an open source project I'm part of called jQuery. I'm trying to get rid of an exception that makes the library partially work on Firefox and completely die in chrome:
uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://dev.johnhamelink.com/jquery/jquewy/latest.js :: anonymous :: line 150" data: no]
I've tried to debug it, and I simply can't get my head around why it's creating an error like this. Any help would be much appreciated!
Edit: forgot to mention, you can view the code here: http://dev.johnhamelink.com/jquery/jquery/
John.
Upvotes: 0
Views: 5462
Reputation: 207501
So I set a breakpoint in Firebug on the first line after the addEvent
function declaration to see what was going on. I added watches for element, type, and callback.
Problem is you are trying to set something to null that can not be set to null.
So you need to add a simple check for null in the addEvent method.
addEvent: function(element, type, callback){
if(!callback) return;
if(element.addEventListener) element.addEventListener(type, callback, false);
else if(element.attachEvent) element.attachEvent('on'+type, callback);
}
Upvotes: 3
Reputation: 207501
There is a nice cutting edge technology error here. Someone copied and pasted wrong.
else if(element.attachEvent) element.attachEvent('on'+element, callback);
Should be 'on'+type
not 'on'+element
.
Upvotes: 1