Skip to main content

Bug Tracker

Side navigation

#7986 closed bug (fixed)

Opened January 16, 2011 08:46PM UTC

Closed February 24, 2012 05:17AM UTC

Last modified May 06, 2012 12:01AM UTC

Bug in $.support.boxModel if page has DIV-element CSS

Reported by: ALLPRO Owned by:
Priority: high Milestone: 1.7.2
Component: support Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

I have a demo page for a plugin that, for simplicity, has a CSS rule like this...

div { padding: 15px; border: 1px solid #999; }

This div rule BREAKS jQuery's $.support logic. The existing jQuery 1.4.4 code is like this... = = "1px";
... = div.offsetWidth === 2;

Because ONLY the leftPadding is specifically set, the DIV inherits defaults for other settings, which causes boxModel, inlineBlockNeedsLayout and shrinkWrapBlocks to be set WRONG in every browser.

It is not common for DIVs to have default styling set, but it is not unreasonable either. Therefore jQuery should handle this use-case by *specifically setting all relevant styles* to avoid errors - ie...

var s =
s.width = s.padding = "1px";
s.border = 0; s.overflow = "hidden";
... = div.offsetWidth === 3;

In the sample above, padding is applied both left & right, so all tests in this section must be changed from '===2' to '===3'. OR paddingRight could be set to 0, but this requires extra code.

This may be a rare bug, but it takes less than a minute to fix it, so hopefully it won't be ignored.

Attachments (0)
Change History (15)

Changed January 16, 2011 11:53PM UTC by jitter comment:1

component: unfiledsupport
milestone: 1.next1.5
priority: undecidedblocker
status: newopen

This test case shows which support properties are affected (in the browser you opened the test case)

Changed January 17, 2011 06:00PM UTC by john comment:2

priority: blockerhigh

We'll tackle this in the next release, not a blocker.

Changed June 05, 2011 03:24PM UTC by rwaldron comment:3

owner: → AaronAsAChimp
status: openassigned

Changed July 12, 2011 03:45PM UTC by ajpiano comment:4

milestone: 1.next1.7

Changed September 22, 2011 02:13PM UTC by dmethvin comment:5

owner: AaronAsAChimpdmethvin

Changed October 10, 2011 04:17PM UTC by dmethvin comment:6

milestone: 1.71.8

Moving to 1.8 for a comprehensive solution.

Changed November 10, 2011 02:01AM UTC by dmethvin comment:7

owner: dmethvin
status: assignedopen

Changed December 06, 2011 05:54PM UTC by dmethvin comment:8

blockedby: → 10413

Changed December 15, 2011 06:10AM UTC by mikesherov comment:9

#5520 is a duplicate of this ticket.

Changed February 24, 2012 05:17AM UTC by Mike Sherov comment:10

resolution: → fixed
status: openclosed

Fix #7986. $.support.boxModel shan't be fooled by page-level CSS.

Changeset: a52391aa1dcf3f28306e274e1b2d7f0affc4e725

Changed March 02, 2012 04:17PM UTC by dmethvin comment:11


Changed March 09, 2012 07:25PM UTC by mikesherov comment:12

#11390 is a duplicate of this ticket.

Changed May 05, 2012 11:09PM UTC by ALLPRO comment:13

The 'fix' to this issue has created a more serious boxModel bug. Now ALL browsers loading a page without a doctype (aka quirks-mode, aka document.compatMode === "CSS1Compat") report $.support.boxModel = false. This is incorrect as non-IE browsers do NOT use the IE box-model in quirks mode. It seems that the correct code should be:

jquery-1.7.2 - line 1455

jQuery.boxModel = support.boxModel = (!jQuery.browser.msie || document.compatMode === "CSS1Compat");

This is a serious bug as any code using $.support.boxModel to decide how to measure and size elements is now broken.

Changed May 05, 2012 11:13PM UTC by dmethvin comment:14

jQuery doesn't support Quirks Mode.'t_Fix#Quirks_Mode

Changed May 06, 2012 12:01AM UTC by ALLPRO comment:15

"jQuery doesn't support Quirks Mode"

Then there would not be a $.support.boxModel property that purports to do so. This is the reason the $.support object exists in the first place. If the code cannot determine what boxModel is in use, how can it be properly handled?

$.boxModel / $.support.boxModel have provided this information since the early versions of jQuery - right up to jQ 1.7.1. The previous boxModel test (create and measure a padded div) made it clear this was the ONLY REASON $.support.boxModel existed. Changing the purpose of this basic property now - without notification - would be ludicrous. It must either be fixed or deprecated.