]> source.dussan.org Git - jquery.git/commitdiff
Fix #6724, though the Mobile Safari wound remains. Closes gh-764.
authorMatt Farmer <matt@frmr.me>
Mon, 14 May 2012 18:12:14 +0000 (14:12 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Mon, 14 May 2012 18:22:51 +0000 (14:22 -0400)
src/dimensions.js
test/unit/dimensions.js

index 9ea688d76d1f91f2f213bbd0dbda308dde85c981..d4d7915ff39f59865449f5adfb71c14546634887 100644 (file)
@@ -28,14 +28,13 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
 
        jQuery.fn[ type ] = function( value ) {
                return jQuery.access( this, function( elem, type, value ) {
-                       var doc, docElemProp, orig, ret;
+                       var doc, orig, ret;
 
                        if ( jQuery.isWindow( elem ) ) {
-                               // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
-                               doc = elem.document;
-                               docElemProp = doc.documentElement[ clientProp ];
-                               return jQuery.support.boxModel && docElemProp ||
-                                       doc.body && doc.body[ clientProp ] || docElemProp;
+                               // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
+                               // isn't a whole lot we can do. See pull request at this URL for discussion:
+                               // https://github.com/jquery/jquery/pull/764
+                               return elem.document.documentElement[ clientProp ];
                        }
 
                        // Get document width or height
index 842072cd4ee69797e380b6933fd184fc6c5c5d26..01135f1a133d1c6157daed23927cc62e29d87ed8 100644 (file)
@@ -9,7 +9,7 @@ function fn( val ) {
 }
 
 function testWidth( val ) {
-       expect(8);
+       expect(9);
 
        var $div = jQuery("#nothiddendiv");
        $div.width( val(30) );
@@ -34,6 +34,8 @@ function testWidth( val ) {
        equal( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
        equal( blah.width(), null, "Make sure 'null' is returned on an empty set");
 
+       equal( jQuery(window).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." );
+
        jQuery.removeData($div[0], "olddisplay", true);
 }
 
@@ -63,7 +65,7 @@ test("width(Function(args))", function() {
 });
 
 function testHeight( val ) {
-       expect(8);
+       expect(9);
 
        var $div = jQuery("#nothiddendiv");
        $div.height( val(30) );
@@ -88,6 +90,8 @@ function testHeight( val ) {
        equal( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
        equal( blah.height(), null, "Make sure 'null' is returned on an empty set");
 
+       equal( jQuery(window).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." );
+
        jQuery.removeData($div[0], "olddisplay", true);
 }