Skip to main content

Bug Tracker

Side navigation

#9417 closed bug (duplicate)

Opened May 25, 2011 07:10AM UTC

Closed June 08, 2011 05:38PM UTC

Last modified June 08, 2011 05:38PM UTC

dimensions are unretrievable on an element whose parent is hidden and does not have any styles set

Reported by: samuel Owned by:
Priority: low Milestone: 1.next
Component: dimensions Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:
Description

<span id="test" style="display:none;">ffffff</span>

$("#test").width() OK

but

<div id="mydiv" style="display:none;">

<span id="test"> ffffff</span>

</div>

$("#test").width() is 0 Error

I can`t get the width when the span in a hidden div

Attachments (0)
Change History (5)

Changed May 25, 2011 02:34PM UTC by timmywil comment:1

blockedby: → 9300
component: unfileddimensions
priority: undecidedlow
status: newopen
version: 1.4.21.6.1

http://jsfiddle.net/timmywil/S8H2w/1/

It would be great if we could get this working, but it's not easy.

Related to #9300. This is different in that this element does not have a width set in its styles to retrieve as a fallback.

Changed May 25, 2011 08:30PM UTC by Mike Sherov <mike.sherov@gmail.com> comment:2

I suppose instead of doing jQuery.swap() on the element itself, we could jQuery.swap all the "display:none;" parents of the element as well... that's a brute force approach, but it may work?

Changed June 08, 2011 01:58AM UTC by timmywil comment:3

summary: a bug on "width()"dimensions are unretrievable on an element whose parent is hidden and does not have any styles set

Changed June 08, 2011 05:38PM UTC by dmethvin comment:4

resolution: → duplicate
status: openclosed

I think we decided this was too gruesome to handle long ago. Mike Sherov's method will often work but would potentially be very slow in the general case. I don't think we'd want to be an enabler of bad practice.

Changed June 08, 2011 05:38PM UTC by dmethvin comment:5

Duplicate of #7618.