Skip to content
Permalink
Browse files

Closes #741: Remove $("body") case in favor of $(document.body).

  • Loading branch information...
dmethvin authored and rwaldron committed Apr 18, 2012
1 parent 376e0d9 commit 532ba250a9f6c5b0f51ec53d68aef9fb148e8dd6
@@ -1,4 +1,4 @@
Copyright (c) 2011 John Resig, http://jquery.com/
Copyright (c) 2012 John Resig, http://jquery.com/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -12,7 +12,8 @@
smarttabs: true,
predef: [
"define",
"DOMParser"
"DOMParser",
"WebKitPoint"
],
maxerr: 100
};
@@ -426,6 +426,8 @@ jQuery.extend({
fireGlobals,
// Loop variable
i,
// Default abort message
strAbort = "canceled",
// Fake xhr
jqXHR = {

@@ -471,7 +473,7 @@ jQuery.extend({

// Cancel the request
abort: function( statusText ) {
statusText = statusText || "abort";
statusText = statusText || strAbort;
if ( transport ) {
transport.abort( statusText );
}
@@ -609,7 +611,7 @@ jQuery.extend({
}
} else {
tmp = map[ jqXHR.status ];
jqXHR.then( tmp, tmp );
jqXHR.always( tmp );
}
}
return this;
@@ -643,7 +645,7 @@ jQuery.extend({

// If request was aborted inside a prefilter, stop there
if ( state === 2 ) {
return false;
return jqXHR;
}

// We can fire global events as of now if asked to
@@ -716,12 +718,14 @@ jQuery.extend({

// Allow custom headers/mimetypes and early abort
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
// Abort if not done already
jqXHR.abort();
return false;
// Abort if not done already and return
return jqXHR.abort();

}

// aborting is no longer a cancelation
strAbort = "abort";

// Install callbacks on deferreds
for ( i in { success: 1, error: 1, complete: 1 } ) {
jqXHR[ i ]( s[ i ] );
@@ -769,7 +773,7 @@ jQuery.extend({
var s = [],
add = function( key, value ) {
// If value is a function, invoke it and return its value
value = jQuery.isFunction( value ) ? value() : value;
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
};

@@ -356,7 +356,12 @@ jQuery.extend({
i = 0;

if ( value && elem.nodeType === 1 ) {
attrNames = value.toLowerCase().split( rspace );

if ( !jQuery.isXMLDoc( elem ) ) {
value = value.toLowerCase();
}

attrNames = value.split( rspace );
l = attrNames.length;

for ( ; i < l; i++ ) {
@@ -38,9 +38,9 @@ function createFlags( flags ) {
*/
jQuery.Callbacks = function( flags ) {

// Convert flags from String-formatted to Object-formatted
// Convert flags from String-formatted to Object-formatted if needed
// (we check in cache first)
flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
flags = typeof flags === "string" ? ( flagsCache[ flags ] || createFlags( flags ) ) : ( flags || {} );

var // Actual callback list
list = [],
@@ -90,15 +90,6 @@ jQuery.fn = jQuery.prototype = {
return this;
}

// The body element only exists once, optimize finding it
if ( selector === "body" && !context && document.body ) {
this.context = document;
this[0] = document.body;
this.selector = selector;
this.length = 1;
return this;
}

// Handle HTML strings
if ( typeof selector === "string" ) {
// Are we dealing with HTML string or an ID?
@@ -132,7 +123,7 @@ jQuery.fn = jQuery.prototype = {
}

} else {
ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
ret = jQuery.buildFragment( [ match[1] ], doc );
selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
}

@@ -200,7 +191,7 @@ jQuery.fn = jQuery.prototype = {
},

toArray: function() {
return slice.call( this, 0 );
return slice.call( this );
},

// Get the Nth element in the matched element set OR
@@ -13,12 +13,35 @@ var ralpha = /alpha\([^)]*\)/i,

// order is important!
cssExpand = [ "Top", "Right", "Bottom", "Left" ],
cssPrefixes = [ "O", "Webkit", "Moz", "ms" ],

curCSS,

getComputedStyle,
currentStyle;

// return a css property mapped to a potentially vendor prefixed property
function vendorPropName( style, name ) {

// shortcut for names that are not vendor prefixed
if ( name in style ) {
return name;
}

// check for vendor prefixed names
var capName = name.charAt(0).toUpperCase() + name.slice(1),
origName = name,
i = cssPrefixes.length;

while ( i-- ) {
name = cssPrefixes[ i ] + capName;
if ( name in style ) {
return name;
}
}

return origName;
}

jQuery.fn.css = function( name, value ) {
return jQuery.access( this, function( elem, name, value ) {
return value !== undefined ?
@@ -72,10 +95,15 @@ jQuery.extend({
}

// Make sure that we're working with the right name
var ret, type, origName = jQuery.camelCase( name ),
style = elem.style, hooks = jQuery.cssHooks[ origName ];
var ret, type, hooks,
origName = jQuery.camelCase( name ),
style = elem.style;

name = jQuery.cssProps[ origName ] || origName;
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );

// gets hook for the prefixed version
// followed by the unprefixed version
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];

// Check if we're setting a value
if ( value !== undefined ) {
@@ -119,12 +147,15 @@ jQuery.extend({
},

css: function( elem, name, extra ) {
var ret, hooks;
var ret, hooks,
origName = jQuery.camelCase( name );

// Make sure that we're working with the right name
name = jQuery.camelCase( name );
hooks = jQuery.cssHooks[ name ];
name = jQuery.cssProps[ name ] || name;
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );

// gets hook for the prefixed version
// followed by the unprefixed version
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];

// cssFloat needs a special treatment
if ( name === "cssFloat" ) {
@@ -241,51 +272,67 @@ curCSS = getComputedStyle || currentStyle;

function getWidthOrHeight( elem, name, extra ) {

// Start with offset property
// Start with offset property, which is equivalent to the border-box value
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
i = name === "width" ? 1 : 0,
len = 4;
len = 4,
valueIsBorderBox = true,
isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";

if ( val <= 0 ) {
// Fall back to computed then uncomputed css if necessary
val = curCSS( elem, name );
if ( val < 0 || val == null ) {
val = elem.style[ name ];
}

if ( val > 0 ) {
if ( extra !== "border" ) {
for ( ; i < len; i += 2 ) {
if ( !extra ) {
val -= parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;
}
if ( extra === "margin" ) {
val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ] ) ) || 0;
} else {
val -= parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
}
}
// Computed unit is not pixels. Stop here and return.
if ( rnumnonpx.test(val) ) {
return val;
}

return val + "px";
}
// we need the check for style in case a browser which returns unreliable values
// for getComputedStyle silently falls back to the reliable elem.style
valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );

// Fall back to computed then uncomputed css if necessary
val = curCSS( elem, name );
if ( val < 0 || val == null ) {
val = elem.style[ name ];
// Normalize "", auto, and prepare for extra
val = parseFloat( val ) || 0;
}

// Computed unit is not pixels. Stop here and return.
if ( rnumnonpx.test(val) ) {
return val;
// determine which box-sizing width we're supposed to be getting
if ( !extra ) {
extra = isBorderBox ? "border" : "content";
}

// Normalize "", auto, and prepare for extra
val = parseFloat( val ) || 0;

// Add padding, border, margin
if ( extra ) {
// if the measurement we need is already represented by the retrieved width
// there's no need to augment further
if ( extra !== (valueIsBorderBox ? "border" : "content") ) {
for ( ; i < len; i += 2 ) {
val += parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;
if ( extra !== "padding" ) {
val += parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
}
// both box models exclude margin, so add it if we want it
if ( extra === "margin" ) {
val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ]) ) || 0;
// we use jQuery.css instead of curCSS here
// because of the reliableMarginRight CSS hook!
val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ] ) ) || 0;
}

if ( valueIsBorderBox ) {
// border-box includes padding, so remove it if we want content
if ( extra === "content" ) {
val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
}

// at this point, extra isnt border nor margin, so remove border
if ( extra !== "margin" ) {
val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
}
} else {
// at this point, extra isnt content, so add padding
val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;

// at this point, extra isnt content nor padding, so add border
if ( extra !== "padding" ) {
val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
}
}
}
}
@@ -320,7 +367,7 @@ if ( !jQuery.support.opacity ) {
get: function( elem, computed ) {
// IE uses filters for opacity
return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
( parseFloat( RegExp.$1 ) / 100 ) + "" :
( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
computed ? "1" : "";
},

@@ -6,6 +6,8 @@ var rbrace = /^(?:\{.*\}|\[.*\])$/,
jQuery.extend({
cache: {},

deletedIds: [],

// Please use with caution
uuid: 0,

@@ -59,7 +61,7 @@ jQuery.extend({
// Only DOM nodes need a new unique ID for each element since their data
// ends up in the global cache
if ( isNode ) {
elem[ internalKey ] = id = ++jQuery.uuid;
elem[ internalKey ] = id = jQuery.deletedIds.pop() || ++jQuery.uuid;
} else {
id = internalKey;
}
@@ -212,6 +214,8 @@ jQuery.extend({
// We destroyed the cache and need to eliminate the expando on the node to avoid
// false lookups in the cache for entries that no longer exist
if ( isNode ) {
jQuery.deletedIds.push( id );

// IE does not allow us to delete expando properties from nodes,
// nor does it have a removeAttribute function on Document nodes;
// we must handle all of these cases

0 comments on commit 532ba25

Please sign in to comment.
You can’t perform that action at this time.