Skip to content
08/01/2010 / dimarzionist

Strange jQuery error

I’ve noticed interesting error in Firefox JavaScript console today within client side code I was working on:

“Could not convert JavaScript argument arg 0 [nsIDOMViewCSS.getComputedStyle]” nsresult: “0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)” location: “JS frame :: /jqueryJsFile/ :: anonymous :: line 809” data: no]’

After half an hour investigation and debug of jQuery internals I found that the reason was in this part of jQuery code:

var computedStyle = defaultView.getComputedStyle( elem, null );

The elem variable was simply text node, something like “&nbsp blah-blah-blah\n”, so because of some bug within JS engine as I can see if was failing to receive styles and it was failing to throw some more readable exception.

The original block of client code that calling jQuery was:

$(someDomNode.nextSibling).hide();

And of course that nextSibling in Firefox was the next space or   after some read element like DIV or LI.

The funny think about this bug is that it was only failing remotely(!) and was working pretty fine on local machine.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: