Skip to content

Commit

Permalink
No ticket. Optimize the marginRight hook: run the support test once o…
Browse files Browse the repository at this point in the history
…nly.
  • Loading branch information
mgol committed Sep 6, 2013
1 parent 73e1201 commit 1f16b16
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,18 @@ jQuery.cssHooks.marginRight = {
delete jQuery.cssHooks.marginRight;
return;
}
if ( computed ) {
// Support: Android 2.3
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
// Work around by temporarily setting element display to inline-block
return jQuery.swap( elem, { "display": "inline-block" },
curCSS, [ elem, "marginRight" ] );
}

jQuery.cssHooks.marginRight.get = function( elem, computed ) {
if ( computed ) {
// Support: Android 2.3
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
// 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 );
}
};

Expand All @@ -480,6 +485,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
delete jQuery.cssHooks[ prop ];
return;
}

jQuery.cssHooks[ prop ].get = function ( i, prop ) {
if ( computed ) {
computed = curCSS( elem, prop );
Expand All @@ -489,6 +495,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
computed;
}
};

return jQuery.cssHooks[ prop ].get( i, prop );
}
};
Expand Down

0 comments on commit 1f16b16

Please sign in to comment.