Side navigation
Ticket #1629: core.diff
File core.diff, 1.9 KB (added by brandon, December 09, 2007 01:03AM UTC)
A possible patch
Index: jquery/src/core.js
===================================================================
--- src/core.js (revision 4089)
+++ src/core.js (working copy)
@@ -779,49 +779,22 @@
css: function( elem, name, force ) {
if ( name == "height" || name == "width" ) {
- var old = {}, height, width;
+ var props = {}, height, width;
+
+ props["position"] = "absolute";
+ props["visibility"] = "hidden";
+ props["display"] = "block";
- // Revert the padding and border widths to get the
- // correct height/width values
- jQuery.each([ "Top", "Bottom", "Right", "Left" ], function(){
- old[ "padding" + this ] = 0;
- old[ "border" + this + "Width" ] = 0;
- });
-
- // Swap out the padding/border values temporarily
- jQuery.swap( elem, old, function() {
-
- // If the element is visible, then the calculation is easy
- if ( jQuery( elem ).is(":visible") ) {
- height = elem.offsetHeight;
- width = elem.offsetWidth;
-
- // Otherwise, we need to flip out more values
- } else {
- elem = jQuery( elem.cloneNode(true) )
- .find(":radio").removeAttr("checked").removeAttr("defaultChecked").end()
- .css({
- visibility: "hidden",
- position: "absolute",
- display: "block",
- right: "0",
- left: "0"
- }).appendTo( elem.parentNode )[0];
-
- var position = jQuery.css( elem.parentNode, "position" ) || "static";
- if ( position == "static" )
- elem.parentNode.style.position = "relative";
-
+ if ( jQuery(elem).is(":visible") ) {
+ height = elem.clientHeight;
+ width = elem.clientWidth;
+ } else {
+ jQuery.swap( elem, props, function() {
height = elem.clientHeight;
- width = elem.clientWidth;
+ width = elem.clientWidth;
+ });
+ }
- if ( position == "static" )
- elem.parentNode.style.position = "static";
-
- elem.parentNode.removeChild( elem );
- }
- });
-
return name == "height" ?
height :
width;
Download in other formats:
Original Format
File core.diff, 1.9 KB (added by brandon, December 09, 2007 01:03AM UTC)
A possible patch
Index: jquery/src/core.js
===================================================================
--- src/core.js (revision 4089)
+++ src/core.js (working copy)
@@ -779,49 +779,22 @@
css: function( elem, name, force ) {
if ( name == "height" || name == "width" ) {
- var old = {}, height, width;
+ var props = {}, height, width;
+
+ props["position"] = "absolute";
+ props["visibility"] = "hidden";
+ props["display"] = "block";
- // Revert the padding and border widths to get the
- // correct height/width values
- jQuery.each([ "Top", "Bottom", "Right", "Left" ], function(){
- old[ "padding" + this ] = 0;
- old[ "border" + this + "Width" ] = 0;
- });
-
- // Swap out the padding/border values temporarily
- jQuery.swap( elem, old, function() {
-
- // If the element is visible, then the calculation is easy
- if ( jQuery( elem ).is(":visible") ) {
- height = elem.offsetHeight;
- width = elem.offsetWidth;
-
- // Otherwise, we need to flip out more values
- } else {
- elem = jQuery( elem.cloneNode(true) )
- .find(":radio").removeAttr("checked").removeAttr("defaultChecked").end()
- .css({
- visibility: "hidden",
- position: "absolute",
- display: "block",
- right: "0",
- left: "0"
- }).appendTo( elem.parentNode )[0];
-
- var position = jQuery.css( elem.parentNode, "position" ) || "static";
- if ( position == "static" )
- elem.parentNode.style.position = "relative";
-
+ if ( jQuery(elem).is(":visible") ) {
+ height = elem.clientHeight;
+ width = elem.clientWidth;
+ } else {
+ jQuery.swap( elem, props, function() {
height = elem.clientHeight;
- width = elem.clientWidth;
+ width = elem.clientWidth;
+ });
+ }
- if ( position == "static" )
- elem.parentNode.style.position = "static";
-
- elem.parentNode.removeChild( elem );
- }
- });
-
return name == "height" ?
height :
width;