Skip to main content

Bug Tracker

Side navigation

#14474 closed bug (wontfix)

Opened October 21, 2013 01:41PM UTC

Closed October 21, 2013 02:24PM UTC

$.support.shrinkWrapBlocks = true if body has display:none

Reported by: v.rovensky@gmc.net Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.1
Keywords: Cc:
Blocked by: Blocking:
Description

Hello, my fellow geeks. I've stumbled upon something strange.

Steps to repro:

Have a display:none on body, check the value of $.support.shrinkWrapBlocks.

jsFiddle: http://jsfiddle.net/VWRzX/

Result:

$.support.shrinkWrapBlocks is true.

Occurs in Chrome 30, IE 10, Safari 5.1.7. Does not occur in Firefox.

Versions:

1.9.1, 1.10.1 (didn't try any older, 2.0+ doesn't seem to have $.support)

Cause:

This is the jQuery logic for shrinkWrapBlocks:

support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );

Chrome, Safari and IE have div.offsetWidth = 0 when the div's parent has display:none.

Is this behavior a bug? It seems pretty wierd to me, I can understand offsetWidth being 0 when the parent is not visible, but having $.support.shrinkWrapBlocks = true makes no sense. The comment in jQuery code suggests that this property should only be set in IE6. Furthermore, it is counterintuitive that a field in $.support should depend on the document structure, I thought that $.support should reflect the browser's capabilities only.

One may argue that $.support is not a public API and should not be relied upon, but this causes other, public APIs to break. In our case it broke an animation that displayed a piece of our page (jQuery set overflow:hidden on something - if it is relevant, check out the defaultPrefilter jQuery method and the only usage of shrinkWrapBlocks therein).

This kinda thing can happen quite easily and, as you can imagine, can be tough to debug.

Attachments (0)
Change History (1)

Changed October 21, 2013 02:24PM UTC by timmywil comment:1

resolution: → wontfix
status: newclosed

The only way I could see to fix this would be to set a style on the body or use an iframe for the support test. Given this is so rare (and that the test will actually be lazy in the 1.11), I don't think we are going to tackle this.