From 6987220d2b561d73ad7c1f92988ffff239f8136b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Go=C5=82e=CC=A8biowski?= Date: Fri, 6 Sep 2013 18:29:53 +0200 Subject: [PATCH] No ticket. Optimize top/left hooks: move the position check up, don't re-check it inside a hook. --- src/css.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/css.js b/src/css.js index 660ed7df6..e40342d2d 100644 --- a/src/css.js +++ b/src/css.js @@ -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; } };