1 import jQuery from "./core.js";
2 import access from "./core/access.js";
3 import isWindow from "./var/isWindow.js";
7 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
8 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
10 padding: "inner" + name,
13 }, function( defaultExtra, funcName ) {
15 // Margin is only for outerHeight, outerWidth
16 jQuery.fn[ funcName ] = function( margin, value ) {
17 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
18 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
20 return access( this, function( elem, type, value ) {
23 if ( isWindow( elem ) ) {
25 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
26 return funcName.indexOf( "outer" ) === 0 ?
27 elem[ "inner" + name ] :
28 elem.document.documentElement[ "client" + name ];
31 // Get document width or height
32 if ( elem.nodeType === 9 ) {
33 doc = elem.documentElement;
35 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
36 // whichever is greatest
38 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
39 elem.body[ "offset" + name ], doc[ "offset" + name ],
40 doc[ "client" + name ]
44 return value === undefined ?
46 // Get width or height on the element, requesting but not forcing parseFloat
47 jQuery.css( elem, type, extra ) :
49 // Set width or height on the element
50 jQuery.style( elem, type, value, extra );
51 }, type, chainable ? margin : undefined, chainable );
56 export default jQuery;