Skip to main content

Bug Tracker

Side navigation

#7693 closed bug (duplicate)

Opened December 03, 2010 02:34PM UTC

Closed January 10, 2011 05:40PM UTC

Last modified January 10, 2011 05:40PM UTC

outerHeight is broken for hidden block's immediate child

Reported by: oleg@elifantiev.ru Owned by:
Priority: low Milestone: 1.6
Component: dimensions Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

Code sample: http://pastebin.com/QgYn10ka

I've got 3 blocks A>B>C.

C has height of 300px and margins of 10px on all sides.

B is hidden via .css('display', 'none'); then C's outerHeight() is calculated.

outerHeight() gives correct answer (300 for specified example), but outerHeight(true) gives incorrect answer (20 for specified example, expected 320 = 300 + 10 * 2).

Attachments (0)
Change History (8)

Changed December 03, 2010 02:39PM UTC by oleg@elifantiev.ru comment:1

Also, here is jsFiddle'd demo: http://jsfiddle.net/pu5Je/

Changed December 08, 2010 09:21PM UTC by jitter comment:2

component: unfileddimensions
keywords: → needsreview
priority: undecidedlow
status: newopen

test case this seems to be valid. It looks like this happens because of the intricate logic to retrieve the dimension of hidden elements.

Hint on internal cause: getWH() returning 0 for outerHeight() but 20 for outerHeight(true) if a margin of 10px is set. This behavior has drastically influences the behavior of the get cssHook for width/height (see the val <= 0 check).

This ticket also relates to #7618 as the reason the "css rule value" is returned instead of the computed value has to do with the same pieces of code.

But one question remains open, I can't find anywhere the jQuery states to support innerHeight/Width, outerHeight/Width(true/false) on hidden elements. The release notes say width()/height() are supported.

Changed December 22, 2010 12:09PM UTC by anonymous comment:3

Seems to affect webkit (only) ?

Changed December 22, 2010 12:23PM UTC by anonymous comment:4

Replying to [comment:3 anonymous]:

Seems to affect webkit (only) ?

AND if the block contains am <img> without height/width styling.

  • but not always. Mostly it works as expected. Very strange..

Changed December 22, 2010 12:41PM UTC by anonymous comment:5

Replying to [comment:4 anonymous]:

Replying to [comment:3 anonymous]: > Seems to affect webkit (only) ? AND if the block contains am <img> without height/width styling. - but not always. Mostly it works as expected. Very strange..

No, sorry. It IS consistent and affects both Mozilla and Webkit (at least):

If the block with overflow:hidden contains an image with out explicit height, and outerHeight() is called during document.ready, the image's height isn't included - which is understandable, but should be mentioned in the API-page for outerHeight()

Changed January 10, 2011 05:40PM UTC by rwaldron comment:6

resolution: → duplicate
status: openclosed

Changed January 10, 2011 05:40PM UTC by rwaldron comment:7

Duplicate of #7618.

Changed January 10, 2011 05:40PM UTC by rwaldron comment:8

keywords: needsreview