Side navigation
Ticket #2071: css.2.diff
File css.2.diff, 2.1 KB (added by brandon, December 17, 2007 11:50PM UTC)
Index: src/core.js
===================================================================
--- src/core.js (revision 4213)
+++ src/core.js (working copy)
@@ -352,9 +352,8 @@
else
selector = jQuery.multiFilter( selector, this );
- var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
return this.filter(function() {
- return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
+ return jQuery.inArray( this, selector ) < 0;
});
},
@@ -764,9 +763,10 @@
// A method for quickly swapping in/out CSS properties to get correct calculations
swap: function( elem, options, callback ) {
+ var old = {};
// Remember the old values, and insert the new ones
for ( var name in options ) {
- elem.style[ "old" + name ] = elem.style[ name ];
+ old[ name ] = elem.style[ name ];
elem.style[ name ] = options[ name ];
}
@@ -774,24 +774,29 @@
// Revert the old values
for ( var name in options )
- elem.style[ name ] = elem.style[ "old" + name ];
+ elem.style[ name ] = old[ name ];
},
css: function( elem, name, force ) {
if ( name == "width" || name == "height" ) {
- var width, height, props = { position: "absolute", visibility: "hidden", display:"block" };
+ var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
function getWH() {
- width = elem.clientWidth;
- height = elem.clientHeight;
+ val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
+ var padding = 0, border = 0;
+ jQuery.each( which, function() {
+ padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ });
+ val -= Math.round(padding + border);
}
if ( jQuery(elem).is(":visible") )
getWH();
else
jQuery.swap( elem, props, getWH );
-
- return name == "width" ? width : height;
+
+ return val;
}
return jQuery.curCSS( elem, name, force );
Download in other formats:
Original Format
File css.2.diff, 2.1 KB (added by brandon, December 17, 2007 11:50PM UTC)
Index: src/core.js
===================================================================
--- src/core.js (revision 4213)
+++ src/core.js (working copy)
@@ -352,9 +352,8 @@
else
selector = jQuery.multiFilter( selector, this );
- var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
return this.filter(function() {
- return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
+ return jQuery.inArray( this, selector ) < 0;
});
},
@@ -764,9 +763,10 @@
// A method for quickly swapping in/out CSS properties to get correct calculations
swap: function( elem, options, callback ) {
+ var old = {};
// Remember the old values, and insert the new ones
for ( var name in options ) {
- elem.style[ "old" + name ] = elem.style[ name ];
+ old[ name ] = elem.style[ name ];
elem.style[ name ] = options[ name ];
}
@@ -774,24 +774,29 @@
// Revert the old values
for ( var name in options )
- elem.style[ name ] = elem.style[ "old" + name ];
+ elem.style[ name ] = old[ name ];
},
css: function( elem, name, force ) {
if ( name == "width" || name == "height" ) {
- var width, height, props = { position: "absolute", visibility: "hidden", display:"block" };
+ var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
function getWH() {
- width = elem.clientWidth;
- height = elem.clientHeight;
+ val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
+ var padding = 0, border = 0;
+ jQuery.each( which, function() {
+ padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ });
+ val -= Math.round(padding + border);
}
if ( jQuery(elem).is(":visible") )
getWH();
else
jQuery.swap( elem, props, getWH );
-
- return name == "width" ? width : height;
+
+ return val;
}
return jQuery.curCSS( elem, name, force );