]> source.dussan.org Git - jquery.git/commitdiff
No ticket. Optimize top/left hooks: move the position check up, don't re-check it...
authorMichał Gołębiowski <m.goleb@gmail.com>
Fri, 6 Sep 2013 16:29:53 +0000 (18:29 +0200)
committerMichał Gołębiowski <m.goleb@gmail.com>
Fri, 6 Sep 2013 16:29:53 +0000 (18:29 +0200)
src/css.js

index 660ed7df6dfb3ec5884a9c120898af2675d7acd3..e40342d2d6a4166c5b6c681b05201bbe223aaf72 100644 (file)
@@ -589,22 +589,20 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
                                return;
                        }
 
-                       if ( pixelPosition ) {
-                               // Hook not needed, remove it.
+                       if ( pixelPosition || !jQuery.fn.position ) {
+                               // Hook not needed or impossible to apply due to a missing module, remove it.
                                // Since there are no other hooks for prop, remove the whole object.
                                delete jQuery.cssHooks[ prop ];
                                return;
                        }
 
                        jQuery.cssHooks[ prop ].get = function ( elem, computed ) {
-                               if ( !support.pixelPosition() && jQuery.fn.position ) {
-                                       if ( computed ) {
-                                               computed = curCSS( elem, prop );
-                                               // if curCSS returns percentage, fallback to offset
-                                               return rnumnonpx.test( computed ) ?
-                                                       jQuery( elem ).position()[ prop ] + "px" :
-                                                       computed;
-                                       }
+                               if ( computed ) {
+                                       computed = curCSS( elem, prop );
+                                       // if curCSS returns percentage, fallback to offset
+                                       return rnumnonpx.test( computed ) ?
+                                               jQuery( elem ).position()[ prop ] + "px" :
+                                               computed;
                                }
                        };