@@ -7,6 +7,7 @@ var ralpha = /alpha\([^)]*\)/i,
7
7
rnumpx = / ^ - ? \d + (?: p x ) ? $ / i,
8
8
rnumnopx = / ^ - ? \d + (? ! p x ) [ ^ \d \s ] + $ / i,
9
9
rrelNum = / ^ ( [ \- + ] ) = ( [ \- + . \d e ] + ) / ,
10
+ rmargin = / ^ m a r g i n / ,
10
11
11
12
cssShow = { position : "absolute" , visibility : "hidden" , display : "block" } ,
12
13
cssWidth = [ "Left" , "Right" ] ,
@@ -256,7 +257,7 @@ jQuery(function() {
256
257
257
258
if ( document . defaultView && document . defaultView . getComputedStyle ) {
258
259
getComputedStyle = function ( elem , name ) {
259
- var ret , defaultView , computedStyle ;
260
+ var ret , defaultView , computedStyle , width , style = elem . style ;
260
261
261
262
name = name . replace ( rupper , "-$1" ) . toLowerCase ( ) ;
262
263
@@ -268,6 +269,16 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
268
269
}
269
270
}
270
271
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
+
271
282
return ret ;
272
283
} ;
273
284
}
@@ -299,7 +310,7 @@ if ( document.documentElement.currentStyle ) {
299
310
if ( rsLeft ) {
300
311
elem . runtimeStyle . left = elem . currentStyle . left ;
301
312
}
302
- style . left = name === "fontSize" ? "1em" : ( ret || 0 ) ;
313
+ style . left = name === "fontSize" ? "1em" : ret ;
303
314
ret = style . pixelLeft + "px" ;
304
315
305
316
// Revert the changed values
0 commit comments