Skip to content
Permalink
Browse files

Fix #11724, $(document).height() in Firefox 12. Closes gh-802.

This reopens #3838 for IE6 which is a regression on a fix in 1.7.2, but we'd rather break a really old IE than a really recent Firefox.
  • Loading branch information
mikesherov authored and dmethvin committed May 29, 2012
1 parent 7428729 commit ba70f8aeb60038ae73b188e432c471f3b115a790
Showing with 20 additions and 16 deletions.
  1. +4 −10 src/dimensions.js
  2. +10 −0 test/data/dimensions/documentSmall.html
  3. +6 −6 test/unit/dimensions.js
@@ -23,20 +23,14 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {

// Get document width or height
if ( elem.nodeType === 9 ) {
// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
doc = elem.documentElement;

// when a window > document, IE6 reports a offset[Width/Height] > client[Width/Height]
// so we can't use max, as it'll choose the incorrect offset[Width/Height]
// instead we use the correct client[Width/Height]
// support:IE6
if ( doc[ clientProp ] >= doc[ scrollProp ] ) {
return doc[ clientProp ];
}

// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
// unfortunately, this causes bug #3838 in IE6 only, but there is currently no good, small way to fix it.
return Math.max(
elem.body[ scrollProp ], doc[ scrollProp ],
elem.body[ offsetProp ], doc[ offsetProp ]
elem.body[ offsetProp ], doc[ offsetProp ],
doc[ clientProp ]
);
}

@@ -2,6 +2,16 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
html {
/**
* we need to null out border-width, because it causes bug #3838
* and until we drop IE6, this test will fail in IE6 if we didn't
* special case this situation.
**/
border-width: 0;
}
</style>
</head>
<body>
<div>
@@ -405,16 +405,16 @@ test("setters with and without box-sizing:border-box", function(){
equal( el.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" );
});

testIframe("dimensions/documentSmall", "window vs. small document", function( jQuery, window, document ) {
testIframe( "dimensions/documentSmall", "window vs. small document", function( jQuery, window, document ) {
expect(2);

equal( jQuery( document ).height(), jQuery( window ).height(), "document height matches window height");
equal( jQuery( document ).width(), jQuery( window ).width(), "document width matches window width");
equal( jQuery( document ).height(), jQuery( window ).height(), "document height matches window height" );
equal( jQuery( document ).width(), jQuery( window ).width(), "document width matches window width" );
});

testIframe("dimensions/documentLarge", "window vs. large document", function( jQuery, window, document ) {
testIframe( "dimensions/documentLarge", "window vs. large document", function( jQuery, window, document ) {
expect(2);

ok( jQuery( document ).height() > jQuery( window ).height(), "document height is larger than window height");
ok( jQuery( document ).width() > jQuery( window ).width(), "document width is larger than window width");
ok( jQuery( document ).height() > jQuery( window ).height(), "document height is larger than window height" );
ok( jQuery( document ).width() > jQuery( window ).width(), "document width is larger than window width" );
});

2 comments on commit ba70f8a

@chicheng

This comment has been minimized.

Copy link

@chicheng chicheng replied Jun 5, 2012

This should be included in release note for Chinese users. LOL (Where IE6 > 40% and FX < 2%)

@scottgonzalez

This comment has been minimized.

Copy link
Member

@scottgonzalez scottgonzalez replied Jun 5, 2012

I'm sure it'll get the same amount of attention as the original fix did. FWIW, this was broken for years and only recently fixed, so it's unlikely that Chinese developers are heavily relying upon this.

Please sign in to comment.
You can’t perform that action at this time.