]> source.dussan.org Git - jquery.git/commitdiff
No ticket. Optimize the marginRight hook: run the support test once only.
authorMichał Gołębiowski <m.goleb@gmail.com>
Fri, 6 Sep 2013 16:33:55 +0000 (18:33 +0200)
committerMichał Gołębiowski <m.goleb@gmail.com>
Fri, 6 Sep 2013 16:33:55 +0000 (18:33 +0200)
src/css.js

index fc59205b1425a1a71d7b6840c5ad6372f95efb7d..a3b9c935b49881161f130eb258409b9c497e1b5a 100644 (file)
@@ -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 );
        }
 };
 
@@ -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 );
@@ -489,6 +495,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
                                                computed;
                                }
                        };
+
                        return jQuery.cssHooks[ prop ].get( i, prop );
                }
        };