开发者

Uncaught exception: "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" line 150"

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开发者_C百科 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.


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.

  • element = dom window object
  • type = "load"
  • callback= null

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);
} 


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜