Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#7693 closed bug (duplicate)

outerHeight is broken for hidden block's immediate child

Reported by: oleg@… 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).

Change History (8)

comment:1 Changed 13 years ago by oleg@…

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

comment:2 Changed 13 years ago by jitter

Component: unfileddimensions
Keywords: needsreview added
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.

comment:3 Changed 13 years ago by anonymous

Seems to affect webkit (only) ?

comment:4 in reply to:  3 ; Changed 13 years ago by anonymous

Replying to 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..

comment:5 in reply to:  4 Changed 13 years ago by anonymous

Replying to anonymous:

Replying to 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()

comment:6 Changed 13 years ago by Rick Waldron

Resolution: duplicate
Status: openclosed

comment:7 Changed 13 years ago by Rick Waldron

Duplicate of #7618.

comment:8 Changed 13 years ago by Rick Waldron

Keywords: needsreview removed
Note: See TracTickets for help on using tickets.