Skip to content
Permalink
Browse files

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

…y)."

This reverts commit 532ba25.
  • Loading branch information...
rwaldron committed Apr 18, 2012
1 parent 532ba25 commit 247d824d35e81ec96e1a8913674c97fb45dd40ae
@@ -1,4 +1,4 @@
Copyright (c) 2012 John Resig, http://jquery.com/
Copyright (c) 2011 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,8 +12,7 @@
smarttabs: true,
predef: [
"define",
"DOMParser",
"WebKitPoint"
"DOMParser"
],
maxerr: 100
};
@@ -426,8 +426,6 @@ jQuery.extend({
fireGlobals,
// Loop variable
i,
// Default abort message
strAbort = "canceled",
// Fake xhr
jqXHR = {

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

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

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

// We can fire global events as of now if asked to
@@ -718,14 +716,12 @@ 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 and return
return jqXHR.abort();
// Abort if not done already
jqXHR.abort();
return false;

}

// 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 ] );
@@ -773,7 +769,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 == null ? "" : value );
value = jQuery.isFunction( value ) ? value() : value;
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
};

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

if ( value && elem.nodeType === 1 ) {

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

attrNames = value.split( rspace );
attrNames = value.toLowerCase().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 if needed
// Convert flags from String-formatted to Object-formatted
// (we check in cache first)
flags = typeof flags === "string" ? ( flagsCache[ flags ] || createFlags( flags ) ) : ( flags || {} );
flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};

var // Actual callback list
list = [],
@@ -90,6 +90,15 @@ 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?
@@ -123,7 +132,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;
}

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

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

// Get the Nth element in the matched element set OR
@@ -13,35 +13,12 @@ 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 ?
@@ -95,15 +72,10 @@ jQuery.extend({
}

// Make sure that we're working with the right name
var ret, type, hooks,
origName = jQuery.camelCase( name ),
style = elem.style;
var ret, type, origName = jQuery.camelCase( name ),
style = elem.style, hooks = jQuery.cssHooks[ 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 ];
name = jQuery.cssProps[ origName ] || origName;

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

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

// Make sure that we're working with the right 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 ];
name = jQuery.camelCase( name );
hooks = jQuery.cssHooks[ name ];
name = jQuery.cssProps[ name ] || name;

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

function getWidthOrHeight( elem, name, extra ) {

// Start with offset property, which is equivalent to the border-box value
// Start with offset property
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
i = name === "width" ? 1 : 0,
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 ];
}
len = 4;

// Computed unit is not pixels. Stop here and return.
if ( rnumnonpx.test(val) ) {
return val;
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;
}
}
}

// 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 ] );
return val + "px";
}

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

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

// if the measurement we need is already represented by the retrieved width
// there's no need to augment further
if ( extra !== (valueIsBorderBox ? "border" : "content") ) {
// Normalize "", auto, and prepare for extra
val = parseFloat( val ) || 0;

// Add padding, border, margin
if ( extra ) {
for ( ; i < len; i += 2 ) {
// both box models exclude margin, so add it if we want it
if ( extra === "margin" ) {
// we use jQuery.css instead of curCSS here
// because of the reliableMarginRight CSS hook!
val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ] ) ) || 0;
val += parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;
if ( extra !== "padding" ) {
val += parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 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;
}
if ( extra === "margin" ) {
val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ]) ) || 0;
}
}
}
@@ -367,7 +320,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) || "" ) ?
( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
( parseFloat( RegExp.$1 ) / 100 ) + "" :
computed ? "1" : "";
},

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

deletedIds: [],

// Please use with caution
uuid: 0,

@@ -61,7 +59,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.deletedIds.pop() || ++jQuery.uuid;
elem[ internalKey ] = id = ++jQuery.uuid;
} else {
id = internalKey;
}
@@ -214,8 +212,6 @@ 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 247d824

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