Non freakish people should ignore this post. It is a solution for a JavaScript bug that doesn’t make a clear signature.

A colleague got this error when trying to implement a jQuery slider plugin called S3 Slider.

uncaught exception: [Exception... "Could not convert JavaScript argument arg 0" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://dev.valugi.ro/lib/jquery/jquery-1.3.2.min.js :: anonymous :: line 12" data: no]

This error is not obvious and not very well documented on other places on web. I saw that is mainly related with various CSS properties. By debugging the plugin I saw that in his case was thrown when he was not passing some spans that the plugin creators take for granted in the HTML code. So I made a demo to simulate the problem. Check the firebug console for the error.

The code to reproduce the error in your Firebug Console:

var itemsSpan = $('span'); // but no spans in page
var currNo = 0;
var x = $(itemsSpan[currNo]); // x defaults to document
console.log(x.css('bottom')); // throws error in jQuery curCSS function

It seems that at line 808 in curCSS function, jQuery throws this error as is unable to output the computed style for the document.
Fast solutions: either add the missing elements, either modify the plugin to check for elements before doing any CSS property retrival.

Update from the bug report that I opened.
In jQuery 1.3.3, $(undefined) will return an empty collection. That will either fix the problem or push it somewhere else. :) You could try the nightly where the patch is already implemented and see how it behaves.

About this entry