mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Offset: Eliminate little-used internal function
Fixes gh-3449 Closes gh-3456
This commit is contained in:
parent
8cb4cd71ef
commit
bf3a43eff8
@ -15,13 +15,6 @@ define( [
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a window from an element
|
|
||||||
*/
|
|
||||||
function getWindow( elem ) {
|
|
||||||
return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
|
|
||||||
}
|
|
||||||
|
|
||||||
jQuery.offset = {
|
jQuery.offset = {
|
||||||
setOffset: function( elem, options, i ) {
|
setOffset: function( elem, options, i ) {
|
||||||
var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
|
var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
|
||||||
@ -86,7 +79,7 @@ jQuery.fn.extend( {
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
var docElem, win, rect, doc,
|
var doc, docElem, rect, win,
|
||||||
elem = this[ 0 ];
|
elem = this[ 0 ];
|
||||||
|
|
||||||
if ( !elem ) {
|
if ( !elem ) {
|
||||||
@ -104,8 +97,8 @@ jQuery.fn.extend( {
|
|||||||
rect = elem.getBoundingClientRect();
|
rect = elem.getBoundingClientRect();
|
||||||
|
|
||||||
doc = elem.ownerDocument;
|
doc = elem.ownerDocument;
|
||||||
win = getWindow( doc );
|
|
||||||
docElem = doc.documentElement;
|
docElem = doc.documentElement;
|
||||||
|
win = doc.defaultView;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
top: rect.top + win.pageYOffset - docElem.clientTop,
|
top: rect.top + win.pageYOffset - docElem.clientTop,
|
||||||
@ -183,7 +176,14 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function(
|
|||||||
|
|
||||||
jQuery.fn[ method ] = function( val ) {
|
jQuery.fn[ method ] = function( val ) {
|
||||||
return access( this, function( elem, method, val ) {
|
return access( this, function( elem, method, val ) {
|
||||||
var win = getWindow( elem );
|
|
||||||
|
// Coalesce documents and windows
|
||||||
|
var win;
|
||||||
|
if ( jQuery.isWindow( elem ) ) {
|
||||||
|
win = elem;
|
||||||
|
} else if ( elem.nodeType === 9 ) {
|
||||||
|
win = elem.defaultView;
|
||||||
|
}
|
||||||
|
|
||||||
if ( val === undefined ) {
|
if ( val === undefined ) {
|
||||||
return win ? win[ prop ] : elem[ method ];
|
return win ? win[ prop ] : elem[ method ];
|
||||||
|
Loading…
Reference in New Issue
Block a user