@@ -7,6 +7,7 @@ var ralpha = /alpha\([^)]*\)/i,
77 rnumpx = / ^ - ? \d + (?: p x ) ? $ / i,
88 rnumnopx = / ^ - ? \d + (? ! p x ) [ ^ \d \s ] + $ / i,
99 rrelNum = / ^ ( [ \- + ] ) = ( [ \- + . \d e ] + ) / ,
10+ rmargin = / ^ m a r g i n / ,
1011
1112 cssShow = { position : "absolute" , visibility : "hidden" , display : "block" } ,
1213 cssWidth = [ "Left" , "Right" ] ,
@@ -256,7 +257,7 @@ jQuery(function() {
256257
257258if ( document . defaultView && document . defaultView . getComputedStyle ) {
258259 getComputedStyle = function ( elem , name ) {
259- var ret , defaultView , computedStyle ;
260+ var ret , defaultView , computedStyle , width , style = elem . style ;
260261
261262 name = name . replace ( rupper , "-$1" ) . toLowerCase ( ) ;
262263
@@ -268,6 +269,16 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
268269 }
269270 }
270271
272+ // A tribute to the "awesome hack by Dean Edwards"
273+ // WebKit uses "computed value (percentage if specified)" instead of "used value" for margins
274+ // which is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
275+ if ( ! jQuery . support . pixelMargin && computedStyle && rmargin . test ( name ) && rnumnopx . test ( ret ) ) {
276+ width = style . width ;
277+ style . width = ret ;
278+ ret = computedStyle . width ;
279+ style . width = width ;
280+ }
281+
271282 return ret ;
272283 } ;
273284}
@@ -299,7 +310,7 @@ if ( document.documentElement.currentStyle ) {
299310 if ( rsLeft ) {
300311 elem . runtimeStyle . left = elem . currentStyle . left ;
301312 }
302- style . left = name === "fontSize" ? "1em" : ( ret || 0 ) ;
313+ style . left = name === "fontSize" ? "1em" : ret ;
303314 ret = style . pixelLeft + "px" ;
304315
305316 // Revert the changed values
0 commit comments