From: Oleg Gaidarenko Date: Wed, 11 Nov 2015 15:48:58 +0000 (+0300) Subject: Revert "Dimensions: outerWidth/Height include scrollbar" X-Git-Tag: 2.2.0~71 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ab7ba382bced1dad67c5a523754d03525cb0bacb;p=jquery.git Revert "Dimensions: outerWidth/Height include scrollbar" This reverts commit 7d44d7f9e7cb73ff2b373f08cea13ea9958bb462. --- diff --git a/src/dimensions.js b/src/dimensions.js index c5f49ac09..30b55fbc0 100644 --- a/src/dimensions.js +++ b/src/dimensions.js @@ -19,10 +19,10 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { if ( jQuery.isWindow( elem ) ) { - // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729) - return funcName.indexOf( "outer" ) === 0 ? - elem[ "inner" + name ] : - elem.document.documentElement[ "client" + name ]; + // 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[ "client" + name ]; } // Get document width or height diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index 28f4ecd13..22b3f0198 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -202,11 +202,10 @@ QUnit.test( "outerWidth()", function( assert ) { var $div, div, $win = jQuery( window ), - $doc = jQuery( document ), - winwidth = $win.prop( "innerWidth" ); + $doc = jQuery( document ); - assert.equal( jQuery( window ).outerWidth(), winwidth, "Test on window without margin option" ); - assert.equal( jQuery( window ).outerWidth( true ), winwidth, "Test on window with margin option" ); + assert.equal( jQuery( window ).outerWidth(), $win.width(), "Test on window without margin option" ); + assert.equal( jQuery( window ).outerWidth( true ), $win.width(), "Test on window with margin option" ); assert.equal( jQuery( document ).outerWidth(), $doc.width(), "Test on document without margin option" ); assert.equal( jQuery( document ).outerWidth( true ), $doc.width(), "Test on document with margin option" ); @@ -236,45 +235,6 @@ QUnit.test( "outerWidth()", function( assert ) { div.remove(); } ); -QUnit.test( "outerHeight()", function( assert ) { - assert.expect( 11 ); - - var $div, div, - $win = jQuery( window ), - $doc = jQuery( document ), - winheight = $win.prop( "innerHeight" ); - - assert.equal( jQuery( window ).outerHeight(), winheight, "Test on window without margin option" ); - assert.equal( jQuery( window ).outerHeight( true ), winheight, "Test on window with margin option" ); - assert.equal( jQuery( document ).outerHeight(), $doc.height(), "Test on document without margin option" ); - assert.equal( jQuery( document ).outerHeight( true ), $doc.height(), "Test on document with margin option" ); - - $div = jQuery( "#nothiddendiv" ); - $div.css( "height", 30 ); - - assert.equal( $div.outerHeight(), 30, "Test with only height set" ); - $div.css( "padding", "20px" ); - assert.equal( $div.outerHeight(), 70, "Test with padding" ); - $div.css( "border", "2px solid #fff" ); - assert.equal( $div.outerHeight(), 74, "Test with padding and border" ); - $div.css( "margin", "10px" ); - assert.equal( $div.outerHeight(), 74, "Test with padding, border and margin without margin option" ); - $div.css( "position", "absolute" ); - assert.equal( $div.outerHeight( true ), 94, "Test with padding, border and margin with margin option" ); - $div.css( "display", "none" ); - assert.equal( $div.outerHeight( true ), 94, "Test hidden div with padding, border and margin with margin option" ); - - // reset styles - $div.css( { "position": "", "display": "", "border": "", "padding": "", "width": "", "height": "" } ); - - div = jQuery( "
" ); - - // Temporarily require 0 for backwards compat - should be auto - assert.equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." ); - - div.remove(); -} ); - QUnit.test( "child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function( assert ) { assert.expect( 16 ); @@ -393,6 +353,43 @@ QUnit.test( "box-sizing:border-box child of a hidden elem (or unconnected node) $divNormal.remove(); } ); +QUnit.test( "outerHeight()", function( assert ) { + assert.expect( 11 ); + + var $div, div, + $win = jQuery( window ), + $doc = jQuery( document ); + + assert.equal( jQuery( window ).outerHeight(), $win.height(), "Test on window without margin option" ); + assert.equal( jQuery( window ).outerHeight( true ), $win.height(), "Test on window with margin option" ); + assert.equal( jQuery( document ).outerHeight(), $doc.height(), "Test on document without margin option" ); + assert.equal( jQuery( document ).outerHeight( true ), $doc.height(), "Test on document with margin option" ); + + $div = jQuery( "#nothiddendiv" ); + $div.css( "height", 30 ); + + assert.equal( $div.outerHeight(), 30, "Test with only width set" ); + $div.css( "padding", "20px" ); + assert.equal( $div.outerHeight(), 70, "Test with padding" ); + $div.css( "border", "2px solid #fff" ); + assert.equal( $div.outerHeight(), 74, "Test with padding and border" ); + $div.css( "margin", "10px" ); + assert.equal( $div.outerHeight(), 74, "Test with padding, border and margin without margin option" ); + assert.equal( $div.outerHeight( true ), 94, "Test with padding, border and margin with margin option" ); + $div.css( "display", "none" ); + assert.equal( $div.outerHeight( true ), 94, "Test hidden div with padding, border and margin with margin option" ); + + // reset styles + $div.css( { "display": "", "border": "", "padding": "", "width": "", "height": "" } ); + + div = jQuery( "
" ); + + // Temporarily require 0 for backwards compat - should be auto + assert.equal( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." ); + + div.remove(); +} ); + QUnit.test( "passing undefined is a setter #5571", function( assert ) { assert.expect( 4 ); assert.equal( jQuery( "#nothiddendiv" ).height( 30 ).height( undefined ).height(), 30, ".height(undefined) is chainable (#5571)" );