]> source.dussan.org Git - jquery.git/commitdiff
Fix #11724, $(document).height() in Firefox 12. Closes gh-802.
authorMike Sherov <mike.sherov@gmail.com>
Tue, 29 May 2012 12:46:00 +0000 (08:46 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Thu, 31 May 2012 16:24:44 +0000 (09:24 -0700)
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.

src/dimensions.js
test/data/dimensions/documentSmall.html
test/unit/dimensions.js

index bbfc62ad8f9a349003e028c168bfb65dbdbe45cd..d81fb327ecf416f071e57139129e64571d4cf8e2 100644 (file)
@@ -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 ]
                                        );
                                }
 
index e0e9a3d54d99dbf756c814717ba4d5821ee0ece9..2d2663328be6076d520eeb2ed0b837c7f3d58909 100644 (file)
@@ -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>
index e2cf6c003f174cde706142fb6c51ac373bb05cf2..49f6bcbadb955853d42bee6b6259a2a14f1231c0 100644 (file)
@@ -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" );
 });