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 comment:1
component: | unfiled → effects |
---|---|
priority: | undecided → low |
status: | new → open |
Changed July 02, 2014 03:52PM UTC by 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 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 comment:4
milestone: | None → 1.12/2.2 |
---|
Agreed. Thanks for the analysis @gibson042!
Changed July 03, 2014 02:57PM UTC by comment:5
owner: | → gibson042 |
---|---|
status: | open → assigned |
Changed October 21, 2014 12:41AM UTC by comment:6
resolution: | → migrated |
---|---|
status: | assigned → closed |
Migrated to https://github.com/jquery/jquery/issues/1776
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()
.