Skip to main content

Bug Tracker

Side navigation

#15169 closed bug (migrated)

Opened June 27, 2014 05:35PM UTC

Closed October 21, 2014 12:41AM UTC

Error with .animate() on plain object

Reported by: dmethvin Owned by: gibson042
Priority: low Milestone: 1.12/2.2
Component: effects Version: 1.11.1
Keywords: Cc:
Blocked by: Blocking:
Description

https://github.com/jquery/api.jquery.com/issues/514

=

Not sure if $.animate intend to support generic object.

The code below raise exception

"Uncaught TypeError: Cannot use 'in' operator to search for 'opacity' in undefined"

var s = { opacity: 1 };
$(s).animate({opacity: 0}, 5000);

But it try to use $.css to set the opacity. So if I just change to other name

var s = { opacity2: 1 };
$(s).animate({opacity2: 0}, 5000);

and it works.

I guess it might be resolvable If jquery can detect if it's the html object or not.

But not sure if $.animate intend to only support html object.

Attachments (0)
Change History (6)

Changed June 30, 2014 02:34PM UTC by timmywil comment:1

component: unfiledeffects
priority: undecidedlow
status: newopen

If we support this, we should support it everywhere. In other words, we should have tests for it everywhere. I think we already do in some places, but the point is let's not just add tests for .animate().

Changed July 02, 2014 03:52PM UTC by gibson042 comment:2

From http://api.jquery.com/animate/:

The .animate() method allows us to create animation effects on any numeric CSS property. The only required parameter is a plain object of CSS properties. This object is similar to the one that can be sent to the .css() method, except that the range of properties is more restrictive.

So we're not explicitly supporting .animate of plain-object properties in our documentation, but this is ''actually'' a bug in the underlying jQuery.Animation (for which we do have unit tests).

The issue appears to be a problematic interaction with jQuery.cssNumber and unit conversion in the default tweener. My inclination is to ignore units unless tween.elem.nodeType === 1, because I don't think there's much of a case (to intentionally understate what's already a dusty corner of the API) for animating non-numeric properties on plain objects... thoughts?

Changed July 03, 2014 02:09PM UTC by timmywil comment:3

Since we have unit tests in this area already, I'd mark this as a regression that should be fixed.

Changed July 03, 2014 02:45PM UTC by dmethvin comment:4

milestone: None1.12/2.2

Agreed. Thanks for the analysis @gibson042!

Changed July 03, 2014 02:57PM UTC by gibson042 comment:5

owner: → gibson042
status: openassigned

Changed October 21, 2014 12:41AM UTC by m_gol comment:6

resolution: → migrated
status: assignedclosed