Skip to content

Commit a52391a

Browse files
mikesherovdmethvin
authored andcommitted
Fix #7986. $.support.boxModel shan't be fooled by page-level CSS.
1 parent 1c35f38 commit a52391a

File tree

5 files changed

+34
-18
lines changed

5 files changed

+34
-18
lines changed

src/css.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ jQuery.extend({
163163
}
164164
});
165165

166-
// DEPRECATED, Use jQuery.css() instead
166+
// DEPRECATED in 1.3, Use jQuery.css() instead
167167
jQuery.curCSS = jQuery.css;
168168

169169
if ( document.defaultView && document.defaultView.getComputedStyle ) {

src/dimensions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
3434
// 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
3535
doc = elem.document;
3636
docElemProp = doc.documentElement[ clientProp ];
37-
return doc.compatMode === "CSS1Compat" && docElemProp ||
37+
return jQuery.support.boxModel && docElemProp ||
3838
doc.body && doc.body[ clientProp ] || docElemProp;
3939
}
4040

src/effects.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ jQuery.fn.extend({
157157
prop[ name ] = prop[ p ];
158158
delete prop[ p ];
159159
}
160-
160+
161161
if ( ( hooks = jQuery.cssHooks[ name ] ) && "expand" in hooks ) {
162162
replace = hooks.expand( prop[ name ] );
163163
delete prop[ name ];
@@ -676,7 +676,7 @@ function defaultDisplay( nodeName ) {
676676
// document to it; WebKit & Firefox won't allow reusing the iframe document.
677677
if ( !iframeDoc || !iframe.createElement ) {
678678
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
679-
iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
679+
iframeDoc.write( ( jQuery.support.boxModel ? "<!doctype html>" : "" ) + "<html><body>" );
680680
iframeDoc.close();
681681
}
682682

src/support.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ jQuery.support = (function() {
9494
pixelMargin: true
9595
};
9696

97+
//jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel instead
98+
jQuery.boxModel = support.boxModel = document.compatMode === "CSS1Compat";
99+
97100
// Make sure checked status is properly cloned
98101
input.checked = true;
99102
support.noCloneChecked = input.cloneNode( true ).checked;
@@ -172,7 +175,8 @@ jQuery.support = (function() {
172175
// Run tests that need a body at doc ready
173176
jQuery(function() {
174177
var container, outer, inner, table, td, offsetSupport,
175-
marginDiv, conMarginTop, ptlm, vb, style, html,
178+
marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight,
179+
paddingMarginBorderVisibility, paddingMarginBorder,
176180
body = document.getElementsByTagName("body")[0];
177181

178182
if ( !body ) {
@@ -181,15 +185,16 @@ jQuery.support = (function() {
181185
}
182186

183187
conMarginTop = 1;
184-
ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;";
185-
vb = "visibility:hidden;border:0;";
186-
style = "style='" + ptlm + "border:5px solid #000;padding:0;'";
187-
html = "<div " + style + "><div></div></div>" +
188-
"<table " + style + " cellpadding='0' cellspacing='0'>" +
188+
paddingMarginBorder = "padding:0;margin:0;border:";
189+
positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;";
190+
paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;";
191+
style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;";
192+
html = "<div " + style + "display:block;'><div style='" + paddingMarginBorder + "0;display:block;overflow:hidden;'></div></div>" +
193+
"<table " + style + "' cellpadding='0' cellspacing='0'>" +
189194
"<tr><td></td></tr></table>";
190195

191196
container = document.createElement("div");
192-
container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
197+
container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
193198
body.insertBefore( container, body.firstChild );
194199

195200
// Construct the test element
@@ -203,8 +208,7 @@ jQuery.support = (function() {
203208
// display:none (it is still safe to use offsets if a parent element is
204209
// hidden; don safety goggles and see bug #4512 for more information).
205210
// (only IE 8 fails this test)
206-
div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
207-
211+
div.innerHTML = "<table><tr><td style='" + paddingMarginBorder + "0;display:none'></td><td>t</td></tr></table>";
208212
tds = div.getElementsByTagName( "td" );
209213
isSupported = ( tds[ 0 ].offsetHeight === 0 );
210214

@@ -241,18 +245,23 @@ jQuery.support = (function() {
241245
// elements when setting their display to 'inline' and giving
242246
// them layout
243247
// (IE < 8 does this)
248+
div.innerHTML = "";
249+
div.style.width = div.style.padding = "1px";
250+
div.style.border = 0;
251+
div.style.overflow = "hidden";
244252
div.style.display = "inline";
245253
div.style.zoom = 1;
246-
support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
254+
support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
247255

248256
// Check if elements with layout shrink-wrap their children
249257
// (IE 6 does this)
250-
div.style.display = "";
251-
div.innerHTML = "<div style='width:4px;'></div>";
252-
support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
258+
div.style.display = "block";
259+
div.style.overflow = "visible";
260+
div.innerHTML = "<div style='width:5px;'></div>";
261+
support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
253262
}
254263

255-
div.style.cssText = ptlm + vb;
264+
div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility;
256265
div.innerHTML = html;
257266

258267
outer = div.firstChild;

test/data/support/bodyBackground.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
body {
77
background: #000000;
88
}
9+
10+
div {
11+
padding: 15px;
12+
border: 1px solid #999;
13+
display: inline;
14+
margin:8px;
15+
}
916
</style>
1017
</head>
1118
<body>

0 commit comments

Comments
 (0)