Skip to main content

Bug Tracker

Side navigation

#12081 closed bug (cantfix)

Opened July 13, 2012 05:57PM UTC

Closed July 13, 2012 09:20PM UTC

jQuery.height() versus style.height inconsistent in Webkit with a transition.

Reported by: jaxesn@gmail.com Owned by: jaxesn@gmail.com
Priority: undecided Milestone: None
Component: unfiled Version: git
Keywords: Cc:
Blocked by: Blocking:
Description

When a transition is in place, in Chrome/Safari, the elm.style.height returns a different value than $elm.height(), right after setting the height property. In Firefox, either access method returns the value which was just set. I'm not sure which behavior is actually correct and/or its even a bug in jQuery or the browsers themselves. Tested with 1.7.2 and the lastest git.

http://jsfiddle.net/t4MqZ/8/

In the fiddle example, if the transition is removed, the functions return the same value. Also, if using a setTimeout longer than the transition time of 2s, the output is the same.

Attachments (0)
Change History (4)

Changed July 13, 2012 08:57PM UTC by dmethvin comment:1

owner: → jaxesn@gmail.com
status: newpending

Both seem correct. You are asking jQuery the **current height** of the element, which is 0px since you just asked Webkit to start transitioning the property a few microseconds earlier in the same thread. I guess it might have gotten to 1px or 3.72px but 0px is an acceptable answer.

If you ask what the value of the property is, well then yes, it will dutifully parrot out the value you just recently assigned.

What values were you expecting?

Changed July 13, 2012 09:08PM UTC by jaxesn@gmail.com comment:2

status: pendingnew

I would expect the values to be the same between browsers, but I certainly see your logic. The issue came up because shortly after the height gets set, the $(body).height(), which is "missing" the 40px, is used to resize the page and the difference between the browsers became a problem.

Its trivial to workaround, but because of the inconsistency, I thought it might be worth pointing out in case anyone had seen it before or runs into again.

Changed July 13, 2012 09:13PM UTC by dmethvin comment:3

If you tried to use the body height while it's still growing due to the transition effect, I think that's another case where it's hard to say what the precise value would be--jQuery or not. What value would you want the body height to reflect at, say, 1/2 second into the transition?

I guess what I'm getting at is, if there's not a clear logical answer then it's probably best not to ask the question. :) We can try to enshrine some answer but that doesn't seem wise.

Changed July 13, 2012 09:20PM UTC by mikesherov comment:4

resolution: → cantfix
status: newclosed

We can't reliably fix this anyway. This is a dupe, but I can't find the dupe at the moment, but this is a cantfix.