Skip to content

Commit

Permalink
Make sure that height/width methods return numbers instead of strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeresig committed Sep 9, 2010
1 parent c168c30 commit cb3a9c1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dimensions.js
Expand Up @@ -8,14 +8,14 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
// innerHeight and innerWidth // innerHeight and innerWidth
jQuery.fn["inner" + name] = function() { jQuery.fn["inner" + name] = function() {
return this[0] ? return this[0] ?
jQuery.css( this[0], type, undefined, false, "padding" ) : parseFloat( jQuery.css( this[0], type, undefined, false, "padding" ), 10 ) :
null; null;
}; };


// outerHeight and outerWidth // outerHeight and outerWidth
jQuery.fn["outer" + name] = function( margin ) { jQuery.fn["outer" + name] = function( margin ) {
return this[0] ? return this[0] ?
jQuery.css( this[0], type, undefined, false, margin ? "margin" : "border" ) : parseFloat( jQuery.css( this[0], type, undefined, false, margin ? "margin" : "border" ), 10 ) :
null; null;
}; };


Expand Down Expand Up @@ -50,7 +50,7 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
// Get or set width or height on the element // Get or set width or height on the element
size === undefined ? size === undefined ?
// Get width or height on the element // Get width or height on the element
jQuery.css( elem, type ) : parseFloat( jQuery.css( elem, type ), 10 ) :


// Set the width or height on the element (default to pixels if value is unitless) // Set the width or height on the element (default to pixels if value is unitless)
this.css( type, typeof size === "string" ? size : size + "px" ); this.css( type, typeof size === "string" ? size : size + "px" );
Expand Down

0 comments on commit cb3a9c1

Please sign in to comment.