Side navigation
#11585 closed bug (worksforme)
Opened April 12, 2012 01:30PM UTC
Closed May 18, 2012 01:54AM UTC
fadeTo sets css display
Reported by: | Knotschi | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | 1.8 |
Component: | css | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
After switching from 1.7.1 to 1.7.2 I had some problems with the fadeTo function.
In older versions the fadeTo function only changed the opacity. But in the newest version it sometimes also changes the display style.
That caused some errors in my application and it took me some time to find these because i couldn't find any changes for the fadeTo function in your release notes.
You can see what I mean here: http://jsfiddle.net/MDVFq/1/
The last console output is "inline" with jquery 1.7.2 but "block" with 1.7.1
Attachments (0)
Change History (8)
Changed April 23, 2012 04:33PM UTC by comment:1
component: | unfiled → css |
---|---|
priority: | undecided → high |
status: | new → open |
Changed April 23, 2012 04:34PM UTC by comment:2
milestone: | None → 1.8 |
---|
Changed May 11, 2012 08:11AM UTC by comment:3
FadeTo and other animate aliases set display for hidden elements to be sure that element will be shown.
Even through disconnected elements (like in your example) always considered to be hidden, but jQuery was failing to set display on them before 1.7.2, like it was described in 10006 ticket.
The thing is, jQuery cannot know beforehand what styles is applied to disconnected nodes and where element will end up with. So to be sure that element will eventually be shown, it sets display on the element.
Easy fix for you will be to use animate for opacity or set css style to:
.test a{display:block !important; text-align:center;}
Changed May 11, 2012 10:03AM UTC by comment:4
I know that behaviour and exactly that was why I used fadeTo instead of fadeIn. In the past I always used fadeTo when I didn't wanted the display to be set.
In the documentation of fadeTo stands only: "The .fadeTo() method animates the opacity of the matched elements."
Nothing with showing or hiding or setting the display.
If you want that new behaviour with also setting the display in fadeTo, you really should write it in the release notes of 1.7.2!! If I would have read it there, I wouldn't had to search for the error in my application so long by my own after changing the jquery version. I didn't thought about you could change the fadeTo behaviour(without writing it in the release notes).
And you also should write that behaviour in the documentation that it not only animates the opacity but also setting the display value / shows the element!
(I prefered the fadeTo behaviour of 1.7.1 with only changing opacity, but that is your decision)
Replying to [comment:3 markel]:
FadeTo and other animate aliases set display for hidden elements to be sure that element will be shown. Even through disconnected elements (like in your example) always considered to be hidden, but jQuery was failing to set display on them before 1.7.2, like it was described in 10006 ticket. The thing is, jQuery cannot know beforehand what styles is applied to disconnected nodes and where element will end up with. So to be sure that element will eventually be shown, it sets display on the element. Easy fix for you will be to use animate for opacity or set css style to:> .test a{display:block !important; text-align:center;}
Changed May 11, 2012 03:50PM UTC by comment:5
Difference between fadeIn and fadeTo methods is only that in fadeIn function you can't specify exact number for opacity, nothing more, all aliases for animate method Always set display for hidden elements, this action is implied for them – how you can see an animation if element is hidden? It doesn't make sense, fadeTo always used jQuery.fn.show for hidden elements, and changes for jQuery.fn.show is in release notes.
To clarify – i'm not a part of jQuery team, i can't write release notes or a documentation, however i'm responsable for this behavior change in newest jQuery. I'm sorry that you spend your time and nerves to find a bug, i know how frustrating it can be, but i really think newst change is the right one.
Changed May 11, 2012 05:09PM UTC by comment:6
Hmm okay, i just looked in the jquery code and see that also in older releases it should have set the display, this just doesn't worked. So it really was a Bug in older version. I always thought the wanted behaviour was without calling show. That explains why there was nothing in the release notes about the fadeTo fn. Nothing changed on fadeTo, only in the show function.
Imho it would be better if somebody writes it in the documentation that it also shows hidden elements. But you are right, I only didn't expected this behaviour because showing doesn't worked in older versions of fadeTo and I got used to it.
But than this here really isn't a Bug and can be closed I think.
Changed May 11, 2012 05:28PM UTC by comment:7
Thank you for understanding, i also created related enchantment because of this ticket – http://bugs.jquery.com/ticket/11755, and associated PR - https://github.com/jquery/jquery/pull/774
If it will be accepted, it will revert previous behavior without breaking #10006 and will make animate set display only if it really need to
Changed May 18, 2012 01:54AM UTC by comment:8
resolution: | → worksforme |
---|---|
status: | open → closed |
This is working as intended.
Confirmed