Bug Tracker

Ticket #1629: core.diff

File core.diff, 1.9 kB (added by brandon, 1 year ago)

A possible patch

  • src/core.js

     
    779779 
    780780    css: function( elem, name, force ) { 
    781781        if ( name == "height" || name == "width" ) { 
    782             var old = {}, height, width; 
     782            var props = {}, height, width; 
     783             
     784            props["position"]   = "absolute"; 
     785            props["visibility"] = "hidden"; 
     786            props["display"]    = "block"; 
    783787 
    784             // Revert the padding and border widths to get the 
    785             // correct height/width values 
    786             jQuery.each([ "Top", "Bottom", "Right", "Left" ], function(){ 
    787                 old[ "padding" + this ] = 0; 
    788                 old[ "border" + this + "Width" ] = 0; 
    789             }); 
    790  
    791             // Swap out the padding/border values temporarily 
    792             jQuery.swap( elem, old, function() { 
    793  
    794                 // If the element is visible, then the calculation is easy 
    795                 if ( jQuery( elem ).is(":visible") ) { 
    796                     height = elem.offsetHeight; 
    797                     width = elem.offsetWidth; 
    798  
    799                 // Otherwise, we need to flip out more values 
    800                 } else { 
    801                     elem = jQuery( elem.cloneNode(true) ) 
    802                         .find(":radio").removeAttr("checked").removeAttr("defaultChecked").end() 
    803                         .css({ 
    804                             visibility: "hidden", 
    805                             position: "absolute", 
    806                             display: "block", 
    807                             right: "0", 
    808                             left: "0" 
    809                         }).appendTo( elem.parentNode )[0]; 
    810  
    811                     var position = jQuery.css( elem.parentNode, "position" ) || "static"; 
    812                     if ( position == "static" ) 
    813                         elem.parentNode.style.position = "relative"; 
    814  
     788            if ( jQuery(elem).is(":visible") ) { 
     789                height = elem.clientHeight; 
     790                width  = elem.clientWidth; 
     791            } else { 
     792                jQuery.swap( elem, props, function() { 
    815793                    height = elem.clientHeight; 
    816                     width = elem.clientWidth; 
     794                    width  = elem.clientWidth; 
     795                }); 
     796            } 
    817797 
    818                     if ( position == "static" ) 
    819                         elem.parentNode.style.position = "static"; 
    820  
    821                     elem.parentNode.removeChild( elem ); 
    822                 } 
    823             }); 
    824  
    825798            return name == "height" ? 
    826799                height : 
    827800                width;