No ticket. Optimize the marginRight hook: run the support test once only.

This commit is contained in:
Michał Gołębiowski 2013-09-06 18:33:55 +02:00
parent 73e120116c
commit 1f16b16859

View File

@ -458,13 +458,18 @@ jQuery.cssHooks.marginRight = {
delete jQuery.cssHooks.marginRight; delete jQuery.cssHooks.marginRight;
return; return;
} }
if ( computed ) {
// Support: Android 2.3 jQuery.cssHooks.marginRight.get = function( elem, computed ) {
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right if ( computed ) {
// Work around by temporarily setting element display to inline-block // Support: Android 2.3
return jQuery.swap( elem, { "display": "inline-block" }, // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
curCSS, [ elem, "marginRight" ] ); // Work around by temporarily setting element display to inline-block
} return jQuery.swap( elem, { "display": "inline-block" },
curCSS, [ elem, "marginRight" ] );
}
};
return jQuery.cssHooks.marginRight.get( elem, computed );
} }
}; };
@ -480,6 +485,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
delete jQuery.cssHooks[ prop ]; delete jQuery.cssHooks[ prop ];
return; return;
} }
jQuery.cssHooks[ prop ].get = function ( i, prop ) { jQuery.cssHooks[ prop ].get = function ( i, prop ) {
if ( computed ) { if ( computed ) {
computed = curCSS( elem, prop ); computed = curCSS( elem, prop );
@ -489,6 +495,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
computed; computed;
} }
}; };
return jQuery.cssHooks[ prop ].get( i, prop ); return jQuery.cssHooks[ prop ].get( i, prop );
} }
}; };