Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#12462 closed bug (wontfix)

getComputedStyle is used without checking the node

Reported by: 229298434@… Owned by: mikesherov
Priority: high Milestone: None
Component: css Version: 1.8.1
Keywords: Cc: dmethvin
Blocked by: Blocking:

Description

In firefox 14,when run this code

$("<a></a>test<a></a>").animate({left:'-100px'})

it will get error message "NS_ERROR_XPC_BAD_CONVERT_JS:Could not convert JavaScript argument arg 0 [nsIDOMWindow.getComputedStyle]"

The reason is that the 'getComputedStyle' method is called without checking the node whether can apply this method.(when the elem is a textnode,it with got error).In the previous version like 1.7.2 you did check this。

Change History (12)

comment:1 Changed 7 years ago by mikesherov

Owner: set to 229298434@…
Status: newpending

Thanks for contributing to the jQuery project! May I ask why you're trying to animate something that can't be animated like a textnode? What's the real world use case here, and what do you expect to happen?

comment:2 in reply to:  1 Changed 7 years ago by anonymous

Replying to mikesherov:

Thanks for contributing to the jQuery project! May I ask why you're trying to animate something that can't be animated like a textnode? What's the real world use case here, and what do you expect to happen?

i use a template engine and it comtain the this html string "<div>.....</div>\n<div>...</div>".The '\n' was convert to a textnode when i put this string to the jQuery selector . so when i call the animate function ,it raise error .I just want to append those node to the dom and show it. and now i must use filter('*') to filter out the textnode.

comment:3 Changed 7 years ago by mikesherov

Owner: changed from 229298434@… to mikesherov
Status: pendingassigned

comment:4 Changed 7 years ago by mikesherov

Component: unfiledcss
Priority: undecidedlow

comment:5 Changed 7 years ago by mikesherov

Owner: changed from mikesherov to 229298434@…
Status: assignedpending

I'm sorry, but this didn't work in jQuery 1.7.2 either in Firefox: http://jsfiddle.net/Lb2zM/1/

Can you show me a situation using jsfiddle in which it did work in 1.7.2 and not in 1.8.0?

comment:6 Changed 7 years ago by anonymous

Here is an example case using ajax where this problem happens when the resulting HTML contains return characters http://jsfiddle.net/RBSF7/1/

comment:7 Changed 7 years ago by mikesherov

Cc: dmethvin added
Owner: changed from 229298434@… to mikesherov
Status: pendingassigned

confirmed. Thanks for the test case. This is clearly a place where jQuery used to "just work". I wonder if it has anything to do with #12523.

dmethvin?

comment:8 Changed 7 years ago by mikesherov

Priority: lowhigh

comment:9 Changed 7 years ago by mikesherov

What's fun about this is that it only ACCIDENTALLY worked for your use case in 1.7.2. I can change it to slideUp and it breaks in 1.7.2 : http://jsfiddle.net/RBSF7/2/

comment:10 Changed 7 years ago by anonymous

'result.hide().slideDown()' work fine in 1.7.2 and should work fine in 1.8.2 also.
I think, this problem caused by '\n' including '<p>some html to echo</p>\n<p>some more html</p>'.
This code work fine without '\n' both in 1.7.2 and in 1.8.2.

comment:11 Changed 7 years ago by mikesherov

Resolution: wontfix
Status: assignedclosed

So I investigated this for a while, and there's no reasonable fix for this. While I can get this to work in FF and Chrome, it was and will always be broken in IE7/6. Really, you should be passing arbitrary HTML to animate as it may contain text nodes.

There are many ways around this in code, one of which you outlined yourself.

For these reasons, I'm marking this as wontfix. Thanks for the bug report!

comment:12 Changed 7 years ago by Slipstreamer

Thanks for this fix it fixed our Drupal installation which is stuck in the dark ages with JQuery. Brillliant!!

Note: See TracTickets for help on using tickets.