Skip to content

Commit

Permalink
Fix #6724, though the Mobile Safari wound remains. Closes jquerygh-764.
Browse files Browse the repository at this point in the history
  • Loading branch information
farmdawgnation authored and dmethvin committed May 14, 2012
1 parent 7778c77 commit ca48d49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions test/unit/dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function fn( val ) {
}

function testWidth( val ) {
expect(8);
expect(9);

var $div = jQuery("#nothiddendiv");
$div.width( val(30) );
Expand All @@ -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);
}

Expand Down Expand Up @@ -63,7 +65,7 @@ test("width(Function(args))", function() {
});

function testHeight( val ) {
expect(8);
expect(9);

var $div = jQuery("#nothiddendiv");
$div.height( val(30) );
Expand All @@ -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);
}

Expand Down

0 comments on commit ca48d49

Please sign in to comment.