开发者

Rolled my own tooltips, Firefox throwing uncaught exception

开发者 https://www.devze.com 2023-01-24 01:44 出处:网络
It seems I\'ve angered Firefox. Here\'s a working JSFiddle of what\'s going on. But, to explain it quickly:

It seems I've angered Firefox. Here's a working JSFiddle of what's going on. But, to explain it quickly:

I'm using Mustache.js to render a template. Then, I'm using .css to set it to display : block and opacity : 0. Then, I'm setting the .offset and animating to opacity : 1.

All works well in Webkit, but not so much in Firefox. I get the following error:

uncaught exception: [Exception... "Could not conv开发者_开发技巧ert JavaScript argument arg 0 [nsIDOMViewCSS.getComputedStyle]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://path/to/jquery-1.4.3.js :: anonymous :: line 5223" data: no]

Any ideas where I might be going wrong here?

The error is only thrown when the .offset and .animate calls are in the code. Else, the code runs fine, although of course, the opacity is not animated to 1.


Remove the comments from typeTemplate and appTemplate.

typeTemplate : "<div class='tooltip'><a href='#' class='close'>Close</a><p>{{appType}}</p></div>",    

appTemplate : "<div class='tooltip'><a href='#' class='close'>Close</a><p class='title'>{{appName}}</p><p>More information coming soon!</p></div>",

I troubleshot it by making a local copy of the site, JSFiddle was bogging down firebug to the point it crashed Firefox. Anyways, I put a debugger on line 5224(where it was dying) of the jQuery source and looked at the last values before it broke.

Here's a screen shot(open it in a new tab) of what I saw in firebug right before the error got thrown. I know it's kinda hard to see but you can read the text in the data value as " end .tooltip". Why it was trying to compute the style of a comment, I don't know :P

Rolled my own tooltips, Firefox throwing uncaught exception


I would add some logging to watch the computed positions/offsets you're setting with CSS. It could be that you're getting a NaN or some other awkward value that the browser doesn't like.

0

精彩评论

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