mirror of
https://github.com/jquery/jquery.git
synced 2026-02-10 11:25:16 -05:00
Remove offset dependency from css. Move curCSS and getStyles to their own modules. -39 bytes. Close gh-1360.
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
define([
|
||||
"./core",
|
||||
"./var/strundefined",
|
||||
"./core/access",
|
||||
"./core/init",
|
||||
"./css",
|
||||
"./selector" // contains
|
||||
], function( jQuery, strundefined, access ) {
|
||||
define(function( require ) {
|
||||
|
||||
var docElem = window.document.documentElement;
|
||||
var
|
||||
jQuery = require( "./core" ),
|
||||
strundefined = require( "./var/strundefined" ),
|
||||
access = require( "./core/access" ),
|
||||
rnumnonpx = require( "./css/var/rnumnonpx" ),
|
||||
curCSS = require( "./css/curCSS" ),
|
||||
support = require( "./css/support" ),
|
||||
docElem = window.document.documentElement;
|
||||
|
||||
require( "./core/init" );
|
||||
require( "./css" );
|
||||
require( "./selector" ); // contains
|
||||
|
||||
/**
|
||||
* Gets a window from an element
|
||||
@@ -177,5 +181,34 @@ jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( me
|
||||
};
|
||||
});
|
||||
|
||||
// Add the top/left cssHooks using jQuery.fn.position
|
||||
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
|
||||
// getComputedStyle returns percent when specified for top/left/bottom/right
|
||||
// rather than make the css module depend on the offset module, we just check for it here
|
||||
jQuery.each( [ "top", "left" ], function( i, prop ) {
|
||||
jQuery.cssHooks[ prop ] = {
|
||||
get: function( elem, computed ) {
|
||||
if ( support.pixelPosition() ) {
|
||||
// Hook not needed, remove it.
|
||||
// Since there are no other hooks for prop, remove the whole object.
|
||||
delete jQuery.cssHooks[ prop ];
|
||||
return;
|
||||
}
|
||||
|
||||
jQuery.cssHooks[ prop ].get = function ( i, prop ) {
|
||||
if ( computed ) {
|
||||
computed = curCSS( elem, prop );
|
||||
// if curCSS returns percentage, fallback to offset
|
||||
return rnumnonpx.test( computed ) ?
|
||||
jQuery( elem ).position()[ prop ] + "px" :
|
||||
computed;
|
||||
}
|
||||
};
|
||||
|
||||
return jQuery.cssHooks[ prop ].get( i, prop );
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
return jQuery;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user