Skip to content

Commit

Permalink
Fix #11724, $(document).height() in Firefox 12. Closes gh-802.
Browse files Browse the repository at this point in the history
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 31, 2012
1 parent 7428729 commit ba70f8a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
14 changes: 4 additions & 10 deletions src/dimensions.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,20 +23,14 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {


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


// when a window > document, IE6 reports a offset[Width/Height] > client[Width/Height] // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
// so we can't use max, as it'll choose the incorrect offset[Width/Height] // unfortunately, this causes bug #3838 in IE6 only, but there is currently no good, small way to fix it.
// instead we use the correct client[Width/Height]
// support:IE6
if ( doc[ clientProp ] >= doc[ scrollProp ] ) {
return doc[ clientProp ];
}

return Math.max( return Math.max(
elem.body[ scrollProp ], doc[ scrollProp ], elem.body[ scrollProp ], doc[ scrollProp ],
elem.body[ offsetProp ], doc[ offsetProp ] elem.body[ offsetProp ], doc[ offsetProp ],
doc[ clientProp ]
); );
} }


Expand Down
10 changes: 10 additions & 0 deletions test/data/dimensions/documentSmall.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <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> </head>
<body> <body>
<div> <div>
Expand Down
12 changes: 6 additions & 6 deletions test/unit/dimensions.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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" ); 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); expect(2);


equal( jQuery( document ).height(), jQuery( window ).height(), "document height matches window height"); 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 ).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); expect(2);


ok( jQuery( document ).height() > jQuery( window ).height(), "document height is larger than window height"); 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 ).width() > jQuery( window ).width(), "document width is larger than window width" );
}); });

2 comments on commit ba70f8a

@chicheng
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@scottgonzalez
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.