Commit 532ba250 authored by Dave Methvin's avatar Dave Methvin Committed by Rick Waldron waldron.rick@gmail.com

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

parent 376e0d9f
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 Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
smarttabs: true, smarttabs: true,
predef: [ predef: [
"define", "define",
"DOMParser" "DOMParser",
"WebKitPoint"
], ],
maxerr: 100 maxerr: 100
}; };
......
...@@ -426,6 +426,8 @@ jQuery.extend({ ...@@ -426,6 +426,8 @@ jQuery.extend({
fireGlobals, fireGlobals,
// Loop variable // Loop variable
i, i,
// Default abort message
strAbort = "canceled",
// Fake xhr // Fake xhr
jqXHR = { jqXHR = {
...@@ -471,7 +473,7 @@ jQuery.extend({ ...@@ -471,7 +473,7 @@ jQuery.extend({
// Cancel the request // Cancel the request
abort: function( statusText ) { abort: function( statusText ) {
statusText = statusText || "abort"; statusText = statusText || strAbort;
if ( transport ) { if ( transport ) {
transport.abort( statusText ); transport.abort( statusText );
} }
...@@ -609,7 +611,7 @@ jQuery.extend({ ...@@ -609,7 +611,7 @@ jQuery.extend({
} }
} else { } else {
tmp = map[ jqXHR.status ]; tmp = map[ jqXHR.status ];
jqXHR.then( tmp, tmp ); jqXHR.always( tmp );
} }
} }
return this; return this;
...@@ -643,7 +645,7 @@ jQuery.extend({ ...@@ -643,7 +645,7 @@ jQuery.extend({
// If request was aborted inside a prefilter, stop there // If request was aborted inside a prefilter, stop there
if ( state === 2 ) { if ( state === 2 ) {
return false; return jqXHR;
} }
// We can fire global events as of now if asked to // We can fire global events as of now if asked to
...@@ -716,12 +718,14 @@ jQuery.extend({ ...@@ -716,12 +718,14 @@ jQuery.extend({
// Allow custom headers/mimetypes and early abort // Allow custom headers/mimetypes and early abort
if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
// Abort if not done already // Abort if not done already and return
jqXHR.abort(); return jqXHR.abort();
return false;
} }
// aborting is no longer a cancelation
strAbort = "abort";
// Install callbacks on deferreds // Install callbacks on deferreds
for ( i in { success: 1, error: 1, complete: 1 } ) { for ( i in { success: 1, error: 1, complete: 1 } ) {
jqXHR[ i ]( s[ i ] ); jqXHR[ i ]( s[ i ] );
...@@ -769,7 +773,7 @@ jQuery.extend({ ...@@ -769,7 +773,7 @@ jQuery.extend({
var s = [], var s = [],
add = function( key, value ) { add = function( key, value ) {
// If value is a function, invoke it and return its 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 ); s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
}; };
......
...@@ -356,7 +356,12 @@ jQuery.extend({ ...@@ -356,7 +356,12 @@ jQuery.extend({
i = 0; i = 0;
if ( value && elem.nodeType === 1 ) { if ( value && elem.nodeType === 1 ) {
attrNames = value.toLowerCase().split( rspace );
if ( !jQuery.isXMLDoc( elem ) ) {
value = value.toLowerCase();
}
attrNames = value.split( rspace );
l = attrNames.length; l = attrNames.length;
for ( ; i < l; i++ ) { for ( ; i < l; i++ ) {
......
...@@ -38,9 +38,9 @@ function createFlags( flags ) { ...@@ -38,9 +38,9 @@ function createFlags( flags ) {
*/ */
jQuery.Callbacks = function( 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) // (we check in cache first)
flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; flags = typeof flags === "string" ? ( flagsCache[ flags ] || createFlags( flags ) ) : ( flags || {} );
var // Actual callback list var // Actual callback list
list = [], list = [],
......
...@@ -90,15 +90,6 @@ jQuery.fn = jQuery.prototype = { ...@@ -90,15 +90,6 @@ jQuery.fn = jQuery.prototype = {
return this; 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 // Handle HTML strings
if ( typeof selector === "string" ) { if ( typeof selector === "string" ) {
// Are we dealing with HTML string or an ID? // Are we dealing with HTML string or an ID?
...@@ -132,7 +123,7 @@ jQuery.fn = jQuery.prototype = { ...@@ -132,7 +123,7 @@ jQuery.fn = jQuery.prototype = {
} }
} else { } else {
ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); ret = jQuery.buildFragment( [ match[1] ], doc );
selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
} }
...@@ -200,7 +191,7 @@ jQuery.fn = jQuery.prototype = { ...@@ -200,7 +191,7 @@ jQuery.fn = jQuery.prototype = {
}, },
toArray: function() { toArray: function() {
return slice.call( this, 0 ); return slice.call( this );
}, },
// Get the Nth element in the matched element set OR // Get the Nth element in the matched element set OR
......
...@@ -13,12 +13,35 @@ var ralpha = /alpha\([^)]*\)/i, ...@@ -13,12 +13,35 @@ var ralpha = /alpha\([^)]*\)/i,
// order is important! // order is important!
cssExpand = [ "Top", "Right", "Bottom", "Left" ], cssExpand = [ "Top", "Right", "Bottom", "Left" ],
cssPrefixes = [ "O", "Webkit", "Moz", "ms" ],
curCSS, curCSS,
getComputedStyle, getComputedStyle,
currentStyle; 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 ) { jQuery.fn.css = function( name, value ) {
return jQuery.access( this, function( elem, name, value ) { return jQuery.access( this, function( elem, name, value ) {
return value !== undefined ? return value !== undefined ?
...@@ -72,10 +95,15 @@ jQuery.extend({ ...@@ -72,10 +95,15 @@ jQuery.extend({
} }
// Make sure that we're working with the right name // Make sure that we're working with the right name
var ret, type, origName = jQuery.camelCase( name ), var ret, type, hooks,
style = elem.style, hooks = jQuery.cssHooks[ origName ]; 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 // Check if we're setting a value
if ( value !== undefined ) { if ( value !== undefined ) {
...@@ -119,12 +147,15 @@ jQuery.extend({ ...@@ -119,12 +147,15 @@ jQuery.extend({
}, },
css: function( elem, name, extra ) { 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 // Make sure that we're working with the right name
name = jQuery.camelCase( name ); name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
hooks = jQuery.cssHooks[ name ];
name = jQuery.cssProps[ name ] || name; // gets hook for the prefixed version
// followed by the unprefixed version
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
// cssFloat needs a special treatment // cssFloat needs a special treatment
if ( name === "cssFloat" ) { if ( name === "cssFloat" ) {
...@@ -241,28 +272,14 @@ curCSS = getComputedStyle || currentStyle; ...@@ -241,28 +272,14 @@ curCSS = getComputedStyle || currentStyle;
function getWidthOrHeight( elem, name, extra ) { 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, var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
i = name === "width" ? 1 : 0, i = name === "width" ? 1 : 0,
len = 4; len = 4,
valueIsBorderBox = true,
if ( val > 0 ) { isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";
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;
}
}
}
return val + "px";
}
if ( val <= 0 ) {
// Fall back to computed then uncomputed css if necessary // Fall back to computed then uncomputed css if necessary
val = curCSS( elem, name ); val = curCSS( elem, name );
if ( val < 0 || val == null ) { if ( val < 0 || val == null ) {
...@@ -274,18 +291,48 @@ function getWidthOrHeight( elem, name, extra ) { ...@@ -274,18 +291,48 @@ function getWidthOrHeight( elem, name, extra ) {
return val; return val;
} }
// 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 ] );
// Normalize "", auto, and prepare for extra // Normalize "", auto, and prepare for extra
val = parseFloat( val ) || 0; val = parseFloat( val ) || 0;
}
// determine which box-sizing width we're supposed to be getting
if ( !extra ) {
extra = isBorderBox ? "border" : "content";
}
// Add padding, border, margin // if the measurement we need is already represented by the retrieved width
if ( extra ) { // there's no need to augment further
if ( extra !== (valueIsBorderBox ? "border" : "content") ) {
for ( ; i < len; i += 2 ) { for ( ; i < len; i += 2 ) {
val += parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0; // 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;
}
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" ) { if ( extra !== "padding" ) {
val += parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
} }
if ( extra === "margin" ) {
val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ]) ) || 0;
} }
} }
} }
...@@ -320,7 +367,7 @@ if ( !jQuery.support.opacity ) { ...@@ -320,7 +367,7 @@ if ( !jQuery.support.opacity ) {
get: function( elem, computed ) { get: function( elem, computed ) {
// IE uses filters for opacity // IE uses filters for opacity
return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
( parseFloat( RegExp.$1 ) / 100 ) + "" : ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
computed ? "1" : ""; computed ? "1" : "";
}, },
......
...@@ -6,6 +6,8 @@ var rbrace = /^(?:\{.*\}|\[.*\])$/, ...@@ -6,6 +6,8 @@ var rbrace = /^(?:\{.*\}|\[.*\])$/,
jQuery.extend({ jQuery.extend({
cache: {}, cache: {},
deletedIds: [],
// Please use with caution // Please use with caution
uuid: 0, uuid: 0,
...@@ -59,7 +61,7 @@ jQuery.extend({ ...@@ -59,7 +61,7 @@ jQuery.extend({
// Only DOM nodes need a new unique ID for each element since their data // Only DOM nodes need a new unique ID for each element since their data
// ends up in the global cache // ends up in the global cache
if ( isNode ) { if ( isNode ) {
elem[ internalKey ] = id = ++jQuery.uuid; elem[ internalKey ] = id = jQuery.deletedIds.pop() || ++jQuery.uuid;
} else { } else {
id = internalKey; id = internalKey;
} }
...@@ -212,6 +214,8 @@ jQuery.extend({ ...@@ -212,6 +214,8 @@ jQuery.extend({
// We destroyed the cache and need to eliminate the expando on the node to avoid // 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 // false lookups in the cache for entries that no longer exist
if ( isNode ) { if ( isNode ) {
jQuery.deletedIds.push( id );
// IE does not allow us to delete expando properties from nodes, // IE does not allow us to delete expando properties from nodes,
// nor does it have a removeAttribute function on Document nodes; // nor does it have a removeAttribute function on Document nodes;
// we must handle all of these cases // we must handle all of these cases
......
...@@ -28,15 +28,11 @@ jQuery.extend({ ...@@ -28,15 +28,11 @@ jQuery.extend({
isResolved: doneList.fired, isResolved: doneList.fired,
isRejected: failList.fired, isRejected: failList.fired,
then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
return this;
},
always: function() { always: function() {
deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
return this; return this;
}, },
pipe: function( fnDone, fnFail, fnProgress ) { then: function( fnDone, fnFail, fnProgress ) {
return jQuery.Deferred(function( newDefer ) { return jQuery.Deferred(function( newDefer ) {
jQuery.each( { jQuery.each( {
done: [ fnDone, "resolve" ], done: [ fnDone, "resolve" ],
...@@ -50,7 +46,7 @@ jQuery.extend({ ...@@ -50,7 +46,7 @@ jQuery.extend({
deferred[ handler ](function() { deferred[ handler ](function() {
returned = fn.apply( this, arguments ); returned = fn.apply( this, arguments );
if ( returned && jQuery.isFunction( returned.promise ) ) { if ( returned && jQuery.isFunction( returned.promise ) ) {
returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); returned.promise().done( newDefer.resolve ).fail( newDefer.reject ).progress( newDefer.notify );
} else { } else {
newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
} }
...@@ -74,9 +70,15 @@ jQuery.extend({ ...@@ -74,9 +70,15 @@ jQuery.extend({
return obj; return obj;
} }
}, },
deferred = promise.promise({}), deferred,
key; key;
// Keep pipe for back-compat
promise.pipe = promise.then;
// Construct deferred
deferred = promise.promise({});
for ( key in lists ) { for ( key in lists ) {
deferred[ key ] = lists[ key ].fire; deferred[ key ] = lists[ key ].fire;
deferred[ key + "With" ] = lists[ key ].fireWith; deferred[ key + "With" ] = lists[ key ].fireWith;
...@@ -100,7 +102,7 @@ jQuery.extend({ ...@@ -100,7 +102,7 @@ jQuery.extend({
// Deferred helper // Deferred helper
when: function( firstParam ) { when: function( firstParam ) {
var args = sliceDeferred.call( arguments, 0 ), var args = sliceDeferred.call( arguments ),
i = 0, i = 0,
length = args.length, length = args.length,
pValues = new Array( length ), pValues = new Array( length ),
...@@ -112,7 +114,7 @@ jQuery.extend({ ...@@ -112,7 +114,7 @@ jQuery.extend({
promise = deferred.promise(); promise = deferred.promise();
function resolveFunc( i ) { function resolveFunc( i ) {
return function( value ) { return function( value ) {
args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments ) : value;
if ( !( --count ) ) { if ( !( --count ) ) {
deferred.resolveWith( deferred, args ); deferred.resolveWith( deferred, args );
} }
...@@ -120,14 +122,14 @@ jQuery.extend({ ...@@ -120,14 +122,14 @@ jQuery.extend({
} }
function progressFunc( i ) { function progressFunc( i ) {
return function( value ) { return function( value ) {
pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments ) : value;
deferred.notifyWith( promise, pValues ); deferred.notifyWith( promise, pValues );
}; };
} }
if ( length > 1 ) { if ( length > 1 ) {
for ( ; i < length; i++ ) { for ( ; i < length; i++ ) {
if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); args[ i ].promise().done( resolveFunc(i) ).fail( deferred.reject ).progress( progressFunc(i) );
} else { } else {
--count; --count;
} }
......
...@@ -59,13 +59,13 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { ...@@ -59,13 +59,13 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
// Get width or height on the element // Get width or height on the element
if ( value === undefined ) { if ( value === undefined ) {
orig = jQuery.css( elem, type ); orig = jQuery.css( elem, type, "content" );
ret = parseFloat( orig ); ret = parseFloat( orig );
return jQuery.isNumeric( ret ) ? ret : orig; return jQuery.isNumeric( ret ) ? ret : orig;
} }
// Set the width or height on the element // Set the width or height on the element
jQuery( elem ).css( type, value ); jQuery.style( elem, type, value );
}, type, value, arguments.length, null ); }, type, value, arguments.length, null );
}; };
}); });
......
...@@ -4,6 +4,7 @@ var elemdisplay = {}, ...@@ -4,6 +4,7 @@ var elemdisplay = {},
iframe, iframeDoc, iframe, iframeDoc,
rfxtypes = /^(?:toggle|show|hide)$/, rfxtypes = /^(?:toggle|show|hide)$/,
rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i, rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
rMarginProp = /^margin/,
timerId, timerId,
fxAttrs = [ fxAttrs = [
// height animations // height animations
...@@ -636,8 +637,8 @@ jQuery.extend( jQuery.fx, { ...@@ -636,8 +637,8 @@ jQuery.extend( jQuery.fx, {
// Ensure props that can't be negative don't go there on undershoot easing // Ensure props that can't be negative don't go there on undershoot easing
jQuery.each( fxAttrs.concat.apply( [], fxAttrs ), function( i, prop ) { jQuery.each( fxAttrs.concat.apply( [], fxAttrs ), function( i, prop ) {
// exclude marginTop, marginLeft, marginBottom and marginRight from this list // Exclude marginTop, marginLeft, marginBottom and marginRight from this list
if ( prop.indexOf( "margin" ) ) { if ( !rMarginProp.test( prop ) ) {
jQuery.fx.step[ prop ] = function( fx ) { jQuery.fx.step[ prop ] = function( fx ) {
jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit ); jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );
}; };
......
...@@ -154,7 +154,7 @@ jQuery.event = { ...@@ -154,7 +154,7 @@ jQuery.event = {
var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
t, tns, type, origType, namespaces, origCount, t, tns, type, origType, namespaces, origCount,
j, events, special, handle, eventType, handleObj; j, events, special, eventType, handleObj;
if ( !elemData || !(events = elemData.events) ) { if ( !elemData || !(events = elemData.events) ) {
return; return;
...@@ -213,14 +213,11 @@ jQuery.event = { ...@@ -213,14 +213,11 @@ jQuery.event = {
// Remove the expando if it's no longer used // Remove the expando if it's no longer used
if ( jQuery.isEmptyObject( events ) ) { if ( jQuery.isEmptyObject( events ) ) {
handle = elemData.handle; delete elemData.handle;
if ( handle ) {
handle.elem = null;
}
// removeData also checks for emptiness and clears the expando if empty // removeData also checks for emptiness and clears the expando if empty
// so use it instead of delete // so use it instead of delete
jQuery.removeData( elem, [ "events", "handle" ], true ); jQuery.removeData( elem, "events", true );
} }
}, },
...@@ -389,7 +386,7 @@ jQuery.event = { ...@@ -389,7 +386,7 @@ jQuery.event = {
var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
delegateCount = handlers.delegateCount, delegateCount = handlers.delegateCount,
args = [].slice.call( arguments, 0 ), args = [].slice.call( arguments ),
run_all = !event.exclusive && !event.namespace, run_all = !event.exclusive && !event.namespace,
special = jQuery.event.special[ event.type ] || {}, special = jQuery.event.special[ event.type ] || {},
handlerQueue = [], handlerQueue = [],
...@@ -636,8 +633,17 @@ jQuery.removeEvent = document.removeEventListener ? ...@@ -636,8 +633,17 @@ jQuery.removeEvent = document.removeEventListener ?
} }
} : } :
function( elem, type, handle ) { function( elem, type, handle ) {
var name = "on" + type;
if ( elem.detachEvent ) { if ( elem.detachEvent ) {
elem.detachEvent( "on" + type, handle );
// #8545, #7054, preventing memory leaks for custom events in IE6-8 –
// detachEvent needed property on element, by name of that event, to properly expose it to GC
if ( typeof elem[ name ] === "undefined" ) {
elem[ name ] = null;
}
elem.detachEvent( name, handle );
} }
}; };
...@@ -819,8 +825,9 @@ if ( !jQuery.support.changeBubbles ) { ...@@ -819,8 +825,9 @@ if ( !jQuery.support.changeBubbles ) {
jQuery.event.add( this, "click._change", function( event ) { jQuery.event.add( this, "click._change", function( event ) {
if ( this._just_changed && !event.isTrigger ) { if ( this._just_changed && !event.isTrigger ) {
this._just_changed = false; this._just_changed = false;
jQuery.event.simulate( "change", this, event, true );
} }
// Allow triggered, simulated change events (#11500)
jQuery.event.simulate( "change", this, event, true );
}); });
} }
return false; return false;
...@@ -1067,4 +1074,3 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl ...@@ -1067,4 +1074,3 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
}); });
})( jQuery ); })( jQuery );
This diff is collapsed.
(function( jQuery ) { (function( jQuery ) {
var getOffset, var getOffset,
rtable = /^t(?:able|d|h)$/i,
rroot = /^(?:body|html)$/i; rroot = /^(?:body|html)$/i;
if ( "getBoundingClientRect" in document.documentElement ) { if ( "getBoundingClientRect" in document.documentElement ) {
getOffset = function( elem, doc, docElem, box ) { getOffset = function( elem, doc, docElem ) {
var box;
try { try {
box = elem.getBoundingClientRect(); box = elem.getBoundingClientRect();
} catch(e) {} } catch(e) {}
...@@ -29,56 +30,12 @@ if ( "getBoundingClientRect" in document.documentElement ) { ...@@ -29,56 +30,12 @@ if ( "getBoundingClientRect" in document.documentElement ) {
} else { } else {
getOffset = function( elem, doc, docElem ) { getOffset = function( elem, doc, docElem ) {
var computedStyle, if ( !jQuery.contains( docElem, elem ) ) {
offsetParent = elem.offsetParent, return { top: 0, left: 0 };
prevOffsetParent = elem,
body = doc.body,
defaultView = doc.defaultView,
prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
top = elem.offsetTop,
left = elem.offsetLeft;
while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
break;
}
computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
top -= elem.scrollTop;
left -= elem.scrollLeft;
if ( elem === offsetParent ) {
top += elem.offsetTop;
left += elem.offsetLeft;
if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
top += parseFloat( computedStyle.borderTopWidth ) || 0;
left += parseFloat( computedStyle.borderLeftWidth ) || 0;
}
prevOffsetParent = offsetParent;
offsetParent = elem.offsetParent;
} }
var point = getWindow( doc ).webkitConvertPointFromNodeToPage( elem, new WebKitPoint( 0, 0 ) );
return { top: point.y, left: point.x };
if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
top += parseFloat( computedStyle.borderTopWidth ) || 0;
left += parseFloat( computedStyle.borderLeftWidth ) || 0;
}
prevComputedStyle = computedStyle;
}
if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
top += body.offsetTop;
left += body.offsetLeft;
}
if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
top += Math.max( docElem.scrollTop, body.scrollTop );
left += Math.max( docElem.scrollLeft, body.scrollLeft );
}
return { top: top, left: left };
}; };
} }
......
...@@ -91,7 +91,8 @@ jQuery.support = (function() { ...@@ -91,7 +91,8 @@ jQuery.support = (function() {
inlineBlockNeedsLayout: false, inlineBlockNeedsLayout: false,
shrinkWrapBlocks: false, shrinkWrapBlocks: false,
reliableMarginRight: true, reliableMarginRight: true,
pixelMargin: true pixelMargin: true,
boxSizingReliable: true
}; };
// jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel instead // jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel instead
...@@ -178,9 +179,9 @@ jQuery.support = (function() { ...@@ -178,9 +179,9 @@ jQuery.support = (function() {
// Run tests that need a body at doc ready // Run tests that need a body at doc ready
jQuery(function() { jQuery(function() {
var container, outer, inner, table, td, offsetSupport, var container, offsetSupport, marginDiv,
marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight, conMarginTop = 1,
paddingMarginBorderVisibility, paddingMarginBorder, boxSizingPrefixes = [ "", "-moz-", "-webkit-", "" ],
body = document.getElementsByTagName("body")[0]; body = document.getElementsByTagName("body")[0];
if ( !body ) { if ( !body ) {
...@@ -188,17 +189,8 @@ jQuery.support = (function() { ...@@ -188,17 +189,8 @@ jQuery.support = (function() {
return; return;
} }
conMarginTop = 1;
paddingMarginBorder = "padding:0;margin:0;border:";
positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;";
paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;";
style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;";
html = "<div " + style + "display:block;'><div style='" + paddingMarginBorder + "0;display:block;overflow:hidden;'></div></div>" +
"<table " + style + "' cellpadding='0' cellspacing='0'>" +
"<tr><td></td></tr></table>";
container = document.createElement("div"); container = document.createElement("div");
container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
body.insertBefore( container, body.firstChild ); body.insertBefore( container, body.firstChild );
// Construct the test element // Construct the test element
...@@ -212,7 +204,7 @@ jQuery.support = (function() { ...@@ -212,7 +204,7 @@ jQuery.support = (function() {
// display:none (it is still safe to use offsets if a parent element is // display:none (it is still safe to use offsets if a parent element is
// hidden; don safety goggles and see bug #4512 for more information). // hidden; don safety goggles and see bug #4512 for more information).
// (only IE 8 fails this test) // (only IE 8 fails this test)
div.innerHTML = "<table><tr><td style='" + paddingMarginBorder + "0;display:none'></td><td>t</td></tr></table>"; div.innerHTML = "<table><tr><td style='padding:0;margin:0;border:0;display:none'></td><td>t</td></tr></table>";
tds = div.getElementsByTagName( "td" ); tds = div.getElementsByTagName( "td" );
isSupported = ( tds[ 0 ].offsetHeight === 0 ); isSupported = ( tds[ 0 ].offsetHeight === 0 );
...@@ -260,35 +252,17 @@ jQuery.support = (function() { ...@@ -260,35 +252,17 @@ jQuery.support = (function() {
support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
} }
div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility; div.style.cssText = boxSizingPrefixes.join("box-sizing:border-box;") + "border:1px;width:4px;padding:1px;display:block;margin-top:1%;";
div.innerHTML = html; support.boxSizing = ( div.offsetWidth === 4 );
if ( window.getComputedStyle ) {
outer = div.firstChild; support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
inner = outer.firstChild; support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%";
td = outer.nextSibling.firstChild.firstChild; }
offsetSupport = { offsetSupport = {
doesNotAddBorder: ( inner.offsetTop !== 5 ), doesNotIncludeMarginInBodyOffset: ( body.offsetTop !== conMarginTop )
doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
}; };
inner.style.position = "fixed";
inner.style.top = "20px";
// safari subtracts parent border width here which is 5px
offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
inner.style.position = inner.style.top = "";
outer.style.overflow = "hidden";
outer.style.position = "relative";
offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
if ( window.getComputedStyle ) {
div.style.marginTop = "1%";
support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%";
}
if ( typeof container.style.zoom !== "undefined" ) { if ( typeof container.style.zoom !== "undefined" ) {
container.style.zoom = 1; container.style.zoom = 1;
......
...@@ -54,7 +54,7 @@ jQuery.fn.extend({ ...@@ -54,7 +54,7 @@ jQuery.fn.extend({
}, },
has: function( target ) { has: function( target ) {
var targets = jQuery( target ); var targets = jQuery( target, this );
return this.filter(function() { return this.filter(function() {
for ( var i = 0, l = targets.length; i < l; i++ ) { for ( var i = 0, l = targets.length; i < l; i++ ) {
if ( jQuery.contains( this, targets[i] ) ) { if ( jQuery.contains( this, targets[i] ) ) {
......
/*jshint multistr:true*/
var jQuery = this.jQuery || "jQuery", // For testing .noConflict() var jQuery = this.jQuery || "jQuery", // For testing .noConflict()
$ = this.$ || "$", $ = this.$ || "$",
originaljQuery = jQuery, originaljQuery = jQuery,
...@@ -45,6 +47,53 @@ function t(a,b,c) { ...@@ -45,6 +47,53 @@ function t(a,b,c) {
deepEqual(f, q.apply(q,c), a + " (" + b + ")"); deepEqual(f, q.apply(q,c), a + " (" + b + ")");
} }
var createDashboardXML = function() {
var string = '<?xml version="1.0" encoding="UTF-8"?> \
<dashboard> \
<locations class="foo"> \
<location for="bar" checked="different"> \
<infowindowtab> \
<tab title="Location"><![CDATA[blabla]]></tab> \
<tab title="Users"><![CDATA[blublu]]></tab> \
</infowindowtab> \
</location> \
</locations> \
</dashboard>';
return jQuery.parseXML(string);
};
var createWithFriesXML = function() {
var string = '<?xml version="1.0" encoding="UTF-8"?> \
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" \
xmlns:xsd="http://www.w3.org/2001/XMLSchema" \
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> \
<soap:Body> \
<jsconf xmlns="http://www.example.com/ns1"> \
<response xmlns:ab="http://www.example.com/ns2"> \
<meta> \
<component id="seite1" class="component"> \
<properties xmlns:cd="http://www.example.com/ns3"> \
<property name="prop1"> \
<thing /> \
<value>1</value> \
</property> \
<property name="prop2"> \
<thing att="something" /> \
</property> \
<foo_bar>foo</foo_bar> \
</properties> \
</component> \
</meta> \
</response> \
</jsconf> \
</soap:Body> \
</soap:Envelope>';
return jQuery.parseXML(string);
};
var fireNative; var fireNative;
if ( document.createEvent ) { if ( document.createEvent ) {
fireNative = function( node, type ) { fireNative = function( node, type ) {
......
...@@ -857,7 +857,7 @@ test("jQuery.ajax - beforeSend", function() { ...@@ -857,7 +857,7 @@ test("jQuery.ajax - beforeSend", function() {
test("jQuery.ajax - beforeSend, cancel request (#2688)", function() { test("jQuery.ajax - beforeSend, cancel request (#2688)", function() {
expect(2); expect(2);
var request = jQuery.ajax({ jQuery.ajax({
url: url("data/name.html"), url: url("data/name.html"),
beforeSend: function() { beforeSend: function() {
ok( true, "beforeSend got called, canceling" ); ok( true, "beforeSend got called, canceling" );
...@@ -872,13 +872,14 @@ test("jQuery.ajax - beforeSend, cancel request (#2688)", function() { ...@@ -872,13 +872,14 @@ test("jQuery.ajax - beforeSend, cancel request (#2688)", function() {
error: function() { error: function() {
ok( false, "request didn't get canceled" ); ok( false, "request didn't get canceled" );
} }
}).fail(function( _, reason ) {
strictEqual( reason, "canceled", "canceled request must fail with 'canceled' status text" );
}); });
ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" );
}); });
test("jQuery.ajax - beforeSend, cancel request manually", function() { test("jQuery.ajax - beforeSend, cancel request manually", function() {
expect(2); expect(2);
var request = jQuery.ajax({ jQuery.ajax({
url: url("data/name.html"), url: url("data/name.html"),
beforeSend: function(xhr) { beforeSend: function(xhr) {
ok( true, "beforeSend got called, canceling" ); ok( true, "beforeSend got called, canceling" );
...@@ -893,8 +894,9 @@ test("jQuery.ajax - beforeSend, cancel request manually", function() { ...@@ -893,8 +894,9 @@ test("jQuery.ajax - beforeSend, cancel request manually", function() {
error: function() { error: function() {
ok( false, "request didn't get canceled" ); ok( false, "request didn't get canceled" );
} }
}).fail(function( _, reason ) {
strictEqual( reason, "canceled", "manually canceled request must fail with 'canceled' status text" );
}); });
ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" );
}); });
window.foobar = null; window.foobar = null;
...@@ -960,13 +962,16 @@ test("serialize()", function() { ...@@ -960,13 +962,16 @@ test("serialize()", function() {
}); });
test("jQuery.param()", function() { test("jQuery.param()", function() {
expect(21); expect(22);
equal( !jQuery.ajaxSettings.traditional, true, "traditional flag, falsy by default" ); equal( !jQuery.ajaxSettings.traditional, true, "traditional flag, falsy by default" );
var params = {foo:"bar", baz:42, quux:"All your base are belong to us"}; var params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
equal( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" ); equal( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
params = {"string":"foo","null":null,"undefined":undefined};
equal( jQuery.param(params), "string=foo&null=&undefined=", "handle nulls and undefineds properly" );
params = {someName: [1, 2, 3], regularThing: "blah" }; params = {someName: [1, 2, 3], regularThing: "blah" };
equal( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3&regularThing=blah", "with array" ); equal( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3&regularThing=blah", "with array" );
...@@ -980,13 +985,13 @@ test("jQuery.param()", function() { ...@@ -980,13 +985,13 @@ test("jQuery.param()", function() {
equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" }; params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
equal( decodeURIComponent( jQuery.param(params) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=undefined&i[]=10&i[]=11&j=true&k=false&l[]=undefined&l[]=0&m=cowboy+hat?", "huge structure" ); equal( decodeURIComponent( jQuery.param(params) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure" );
params = { a: [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { b: [ 7, [ 8, 9 ], [ { c: 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { e: { f: { g: [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] }; params = { a: [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { b: [ 7, [ 8, 9 ], [ { c: 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { e: { f: { g: [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] };
equal( decodeURIComponent( jQuery.param(params) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" ); equal( decodeURIComponent( jQuery.param(params) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" );
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" }; params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
equal( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" ); equal( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" );
equal( decodeURIComponent( jQuery.param({ a: [1,2,3], "b[]": [4,5,6], "c[d]": [7,8,9], e: { f: [10], g: [11,12], h: 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." ); equal( decodeURIComponent( jQuery.param({ a: [1,2,3], "b[]": [4,5,6], "c[d]": [7,8,9], e: { f: [10], g: [11,12], h: 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." );
...@@ -1011,16 +1016,16 @@ test("jQuery.param()", function() { ...@@ -1011,16 +1016,16 @@ test("jQuery.param()", function() {
equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" }; params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
equal( jQuery.param(params), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure" ); equal( jQuery.param(params), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure" );
params = { a: [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { b: [ 7, [ 8, 9 ], [ { c: 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { e: { f: { g: [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] }; params = { a: [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { b: [ 7, [ 8, 9 ], [ { c: 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { e: { f: { g: [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] };
equal( jQuery.param(params), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" ); equal( jQuery.param(params), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" );
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" }; params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
equal( decodeURIComponent( jQuery.param(params,false) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=undefined&i[]=10&i[]=11&j=true&k=false&l[]=undefined&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" ); equal( decodeURIComponent( jQuery.param(params,false) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" );
params = { param1: null }; params = { param1: null };
equal( jQuery.param(params,false), "param1=null", "Make sure that null params aren't traversed." ); equal( jQuery.param(params,false), "param1=", "Make sure that null params aren't traversed." );
params = {"test": {"length": 3, "foo": "bar"} }; params = {"test": {"length": 3, "foo": "bar"} };
equal( jQuery.param( params, false ), "test%5Blength%5D=3&test%5Bfoo%5D=bar", "Sub-object with a length property" ); equal( jQuery.param( params, false ), "test%5Blength%5D=3&test%5Bfoo%5D=bar", "Sub-object with a length property" );
...@@ -2109,13 +2114,14 @@ test( "jQuery.ajax - Context with circular references (#9887)", 2, function () { ...@@ -2109,13 +2114,14 @@ test( "jQuery.ajax - Context with circular references (#9887)", 2, function () {
context = {}; context = {};
context.field = context; context.field = context;
try { try {
success = !jQuery.ajax( "non-existing", { jQuery.ajax( "non-existing", {
context: context, context: context,
beforeSend: function() { beforeSend: function() {
ok( this === context, "context was not deep extended" ); ok( this === context, "context was not deep extended" );
return false; return false;
} }
}); });
success = true;
} catch (e) { console.log( e ); } } catch (e) { console.log( e ); }
ok( success, "context with circular reference did not generate an exception" ); ok( success, "context with circular reference did not generate an exception" );
}); });
...@@ -2315,12 +2321,14 @@ test("jQuery.ajax - abort in prefilter", function() { ...@@ -2315,12 +2321,14 @@ test("jQuery.ajax - abort in prefilter", function() {
} }
}); });
strictEqual( jQuery.ajax({ jQuery.ajax({
abortInPrefilter: true, abortInPrefilter: true,
error: function() { error: function() {
ok( false, "error callback called" ); ok( false, "error callback called" );
} }
}), false, "Request was properly aborted early by the prefilter" ); }).fail(function( _, reason ) {
strictEqual( reason, 'canceled', "Request aborted by the prefilter must fail with 'canceled' status text" );
});
}); });
......
...@@ -127,18 +127,13 @@ test("attr(String)", function() { ...@@ -127,18 +127,13 @@ test("attr(String)", function() {
equal( $form.prop("enctype"), "multipart/form-data", "Set the enctype of a form (encoding in IE6/7 #6743)" ); equal( $form.prop("enctype"), "multipart/form-data", "Set the enctype of a form (encoding in IE6/7 #6743)" );
}); });
if ( !isLocal ) { test("attr(String) in XML Files", function() {
test("attr(String) in XML Files", function() {
expect(3); expect(3);
stop(); var xml = createDashboardXML();
jQuery.get("data/dashboard.xml", function( xml ) {
equal( jQuery( "locations", xml ).attr("class"), "foo", "Check class attribute in XML document" ); equal( jQuery( "locations", xml ).attr("class"), "foo", "Check class attribute in XML document" );
equal( jQuery( "location", xml ).attr("for"), "bar", "Check for attribute in XML document" ); equal( jQuery( "location", xml ).attr("for"), "bar", "Check for attribute in XML document" );
equal( jQuery( "location", xml ).attr("checked"), "different", "Check that hooks are not attached in XML document" ); equal( jQuery( "location", xml ).attr("checked"), "different", "Check that hooks are not attached in XML document" );
start(); });
});
});
}
test("attr(String, Function)", function() { test("attr(String, Function)", function() {
expect(2); expect(2);
...@@ -392,21 +387,16 @@ test("attr(jquery_method)", function(){ ...@@ -392,21 +387,16 @@ test("attr(jquery_method)", function(){
equal( elem.style.paddingRight, "1px", "attr({...})"); equal( elem.style.paddingRight, "1px", "attr({...})");
}); });
if ( !isLocal ) { test("attr(String, Object) - Loaded via XML document", function() {
test("attr(String, Object) - Loaded via XML document", function() {
expect(2); expect(2);
stop(); var xml = createDashboardXML();
jQuery.get("data/dashboard.xml", function( xml ) {
var titles = []; var titles = [];
jQuery( "tab", xml ).each(function() { jQuery( "tab", xml ).each(function() {
titles.push( jQuery(this).attr("title") ); titles.push( jQuery(this).attr("title") );
}); });
equal( titles[0], "Location", "attr() in XML context: Check first title" ); equal( titles[0], "Location", "attr() in XML context: Check first title" );
equal( titles[1], "Users", "attr() in XML context: Check second title" ); equal( titles[1], "Users", "attr() in XML context: Check second title" );
start(); });
});
});
}
test("attr('tabindex')", function() { test("attr('tabindex')", function() {
expect(8); expect(8);
...@@ -1192,3 +1182,16 @@ test("coords returns correct values in IE6/IE7, see #10828", function() { ...@@ -1192,3 +1182,16 @@ test("coords returns correct values in IE6/IE7, see #10828", function() {
area = map.html("<area shape='rect' href='#' alt='a' /></map>").find("area"); area = map.html("<area shape='rect' href='#' alt='a' /></map>").find("area");
equal( area.attr("coords"), undefined, "did not retrieve coords correctly"); equal( area.attr("coords"), undefined, "did not retrieve coords correctly");
}); });
test("Handle cased attributes on XML DOM correctly in removeAttr()", function() {
expect(1);
var xmlStr = "<root><item fooBar='123' /></root>",
$xmlDoc = jQuery( jQuery.parseXML( xmlStr ) ),
$item = $xmlDoc.find( "item" ),
el = $item[0];
$item.removeAttr( "fooBar" );
equal( el.attributes.length, 0, "attribute with upper case did not get removed" );
});
...@@ -33,11 +33,32 @@ var output, ...@@ -33,11 +33,32 @@ var output,
} }
}; };
jQuery.each( tests, function( flags, resultString ) { function showFlags( flags ) {
if ( typeof flags === "string" ) {
return '"' + flags + '"';
}
var output = [], key;
for ( key in flags ) {
output.push( '"' + key + '": ' + flags[ key ] );
}
return "{ " + output.join( ", " ) + " }";
}
jQuery.each( tests, function( strFlags, resultString ) {
var objectFlags = {};
jQuery.each( strFlags.split( " " ), function() {
if ( this.length ) {
objectFlags[ this ] = true;
}
});
jQuery.each( filters, function( filterLabel, filter ) { jQuery.each( filters, function( filterLabel, filter ) {
test( "jQuery.Callbacks( \"" + flags + "\" ) - " + filterLabel, function() { jQuery.each( { "string": strFlags, "object": objectFlags }, function( flagsTypes, flags ) {
test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function() {
expect( 20 ); expect( 20 );
...@@ -178,6 +199,7 @@ jQuery.each( tests, function( flags, resultString ) { ...@@ -178,6 +199,7 @@ jQuery.each( tests, function( flags, resultString ) {
}); });
}); });
});
}); });
})(); })();
...@@ -547,21 +547,16 @@ test("XSS via location.hash", function() { ...@@ -547,21 +547,16 @@ test("XSS via location.hash", function() {
jQuery( '#<img id="check9521" src="no-such-.gif" onerror="jQuery._check9521(false)">' ).appendTo("#qunit-fixture"); jQuery( '#<img id="check9521" src="no-such-.gif" onerror="jQuery._check9521(false)">' ).appendTo("#qunit-fixture");
} catch (err) { } catch (err) {
jQuery._check9521(true); jQuery._check9521(true);
}; }
}); });
if ( !isLocal ) {
test("isXMLDoc - XML", function() { test("isXMLDoc - XML", function() {
expect(3); expect(3);
stop(); var xml = createDashboardXML();
jQuery.get("data/dashboard.xml", function(xml) {
ok( jQuery.isXMLDoc( xml ), "XML document" ); ok( jQuery.isXMLDoc( xml ), "XML document" );
ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" ); ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" );
ok( jQuery.isXMLDoc( jQuery("tab", xml)[0] ), "XML Tab Element" ); ok( jQuery.isXMLDoc( jQuery("tab", xml)[0] ), "XML Tab Element" );
start();
});
}); });
}
test("isWindow", function() { test("isWindow", function() {
expect( 14 ); expect( 14 );
...@@ -638,20 +633,16 @@ test("jQuery('html', context)", function() { ...@@ -638,20 +633,16 @@ test("jQuery('html', context)", function() {
equal($span.length, 1, "Verify a span created with a div context works, #1763"); equal($span.length, 1, "Verify a span created with a div context works, #1763");
}); });
if ( !isLocal ) {
test("jQuery(selector, xml).text(str) - Loaded via XML document", function() { test("jQuery(selector, xml).text(str) - Loaded via XML document", function() {
expect(2); expect(2);
stop();
jQuery.get("data/dashboard.xml", function(xml) { var xml = createDashboardXML();
// tests for #1419 where IE was a problem // tests for #1419 where IE was a problem
var tab = jQuery("tab", xml).eq(0); var tab = jQuery("tab", xml).eq(0);
equal( tab.text(), "blabla", "Verify initial text correct" ); equal( tab.text(), "blabla", "Verify initial text correct" );
tab.text("newtext"); tab.text("newtext");
equal( tab.text(), "newtext", "Verify new text correct" ); equal( tab.text(), "newtext", "Verify new text correct" );
start();
});
}); });
}
test("end()", function() { test("end()", function() {
expect(3); expect(3);
......
...@@ -555,6 +555,18 @@ test("outerWidth(true) and css('margin') returning % instead of px in Webkit, se ...@@ -555,6 +555,18 @@ test("outerWidth(true) and css('margin') returning % instead of px in Webkit, se
equal( el.outerWidth(true), 400, "outerWidth(true) and css('margin') returning % instead of px in Webkit, see #10639" ); equal( el.outerWidth(true), 400, "outerWidth(true) and css('margin') returning % instead of px in Webkit, see #10639" );
}); });
test("css('width') should respect box-sizing, see #11004", function() {
var el_disconnected = jQuery("<div style='width:300px;margin:2px;padding:2px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;'>test</div>"),
el = el_disconnected.clone().appendTo("#qunit-fixture"),
width_initial = el.css("width"),
width_roundtrip = el.css("width", el.css("width")).css("width"),
width_initial_disconnected = el_disconnected.css("width"),
width_roundtrip_disconnected = el_disconnected.css("width", el_disconnected.css("width")).css("width");
equal( width_roundtrip, width_initial, "css('width') is not respecting box-sizing, see #11004");
equal( width_roundtrip_disconnected, width_initial_disconnected, "css('width') is not respecting box-sizing for disconnected element, see #11004");
});
test( "cssHooks - expand", function() { test( "cssHooks - expand", function() {
expect( 15 ); expect( 15 );
var result, var result,
......
...@@ -184,9 +184,6 @@ test(".data()", function() { ...@@ -184,9 +184,6 @@ test(".data()", function() {
var dataObj = div.data(); var dataObj = div.data();
// TODO: Remove this hack which was introduced in 1.5.1
delete dataObj.toJSON;
deepEqual( dataObj, {test: "success"}, "data() get the entire data object" ); deepEqual( dataObj, {test: "success"}, "data() get the entire data object" );
strictEqual( div.data("foo"), undefined, "Make sure that missing result is still undefined" ); strictEqual( div.data("foo"), undefined, "Make sure that missing result is still undefined" );
...@@ -198,9 +195,6 @@ test(".data()", function() { ...@@ -198,9 +195,6 @@ test(".data()", function() {
dataObj = jQuery.extend(true, {}, jQuery(obj).data()); dataObj = jQuery.extend(true, {}, jQuery(obj).data());
// TODO: Remove this hack which was introduced for 1.5.1
delete dataObj.toJSON;
deepEqual( dataObj, { foo: "baz" }, "Retrieve data object from a wrapped JS object (#7524)" ); deepEqual( dataObj, { foo: "baz" }, "Retrieve data object from a wrapped JS object (#7524)" );
}); });
......
...@@ -8,32 +8,36 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { ...@@ -8,32 +8,36 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
test("jQuery.Deferred" + withNew, function() { test("jQuery.Deferred" + withNew, function() {
expect( 22 ); expect( 23 );
var defer = createDeferred();
createDeferred().resolve().then( function() { strictEqual( defer.pipe, defer.then, "pipe is an alias of then" );
createDeferred().resolve().done(function() {
ok( true , "Success on resolve" ); ok( true , "Success on resolve" );
ok( this.isResolved(), "Deferred is resolved" ); ok( this.isResolved(), "Deferred is resolved" );
strictEqual( this.state(), "resolved", "Deferred is resolved (state)" ); strictEqual( this.state(), "resolved", "Deferred is resolved (state)" );
}, function() { }).fail(function() {
ok( false , "Error on resolve" ); ok( false , "Error on resolve" );
}).always( function() { }).always(function() {
ok( true , "Always callback on resolve" ); ok( true , "Always callback on resolve" );
}); });
createDeferred().reject().then( function() { createDeferred().reject().done(function() {
ok( false , "Success on reject" ); ok( false , "Success on reject" );
}, function() { }).fail(function() {
ok( true , "Error on reject" ); ok( true , "Error on reject" );
ok( this.isRejected(), "Deferred is rejected" ); ok( this.isRejected(), "Deferred is rejected" );
strictEqual( this.state(), "rejected", "Deferred is rejected (state)" ); strictEqual( this.state(), "rejected", "Deferred is rejected (state)" );
}).always( function() { }).always(function() {
ok( true , "Always callback on reject" ); ok( true , "Always callback on reject" );
}); });
createDeferred( function( defer ) { createDeferred(function( defer ) {
ok( this === defer , "Defer passed as this & first argument" ); ok( this === defer , "Defer passed as this & first argument" );
this.resolve( "done" ); this.resolve( "done" );
}).then( function( value ) { }).done( function( value ) {
strictEqual( value , "done" , "Passed function executed" ); strictEqual( value , "done" , "Passed function executed" );
}); });
...@@ -58,7 +62,7 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { ...@@ -58,7 +62,7 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
test( "jQuery.Deferred - chainability", function() { test( "jQuery.Deferred - chainability", function() {
var methods = "resolve reject notify resolveWith rejectWith notifyWith done fail progress then always".split( " " ), var methods = "resolve reject notify resolveWith rejectWith notifyWith done fail progress always".split( " " ),
defer = jQuery.Deferred(); defer = jQuery.Deferred();
expect( methods.length ); expect( methods.length );
...@@ -69,12 +73,12 @@ test( "jQuery.Deferred - chainability", function() { ...@@ -69,12 +73,12 @@ test( "jQuery.Deferred - chainability", function() {
}); });
}); });
test( "jQuery.Deferred.pipe - filtering (done)", function() { test( "jQuery.Deferred.then - filtering (done)", function() {
expect(4); expect(4);
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.pipe(function( a, b ) { piped = defer.then(function( a, b ) {
return a * b; return a * b;
}), }),
value1, value1,
...@@ -96,21 +100,21 @@ test( "jQuery.Deferred.pipe - filtering (done)", function() { ...@@ -96,21 +100,21 @@ test( "jQuery.Deferred.pipe - filtering (done)", function() {
strictEqual( value2, 3, "second resolve value ok" ); strictEqual( value2, 3, "second resolve value ok" );
strictEqual( value3, 6, "result of filter ok" ); strictEqual( value3, 6, "result of filter ok" );
jQuery.Deferred().reject().pipe(function() { jQuery.Deferred().reject().then(function() {
ok( false, "pipe should not be called on reject" ); ok( false, "then should not be called on reject" );
}); });
jQuery.Deferred().resolve().pipe( jQuery.noop ).done(function( value ) { jQuery.Deferred().resolve().then( jQuery.noop ).done(function( value ) {
strictEqual( value, undefined, "pipe done callback can return undefined/null" ); strictEqual( value, undefined, "then done callback can return undefined/null" );
}); });
}); });
test( "jQuery.Deferred.pipe - filtering (fail)", function() { test( "jQuery.Deferred.then - filtering (fail)", function() {
expect(4); expect(4);
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.pipe( null, function( a, b ) { piped = defer.then( null, function( a, b ) {
return a * b; return a * b;
} ), } ),
value1, value1,
...@@ -132,21 +136,21 @@ test( "jQuery.Deferred.pipe - filtering (fail)", function() { ...@@ -132,21 +136,21 @@ test( "jQuery.Deferred.pipe - filtering (fail)", function() {
strictEqual( value2, 3, "second reject value ok" ); strictEqual( value2, 3, "second reject value ok" );
strictEqual( value3, 6, "result of filter ok" ); strictEqual( value3, 6, "result of filter ok" );
jQuery.Deferred().resolve().pipe( null, function() { jQuery.Deferred().resolve().then( null, function() {
ok( false, "pipe should not be called on resolve" ); ok( false, "then should not be called on resolve" );
} ); } );
jQuery.Deferred().reject().pipe( null, jQuery.noop ).fail(function( value ) { jQuery.Deferred().reject().then( null, jQuery.noop ).fail(function( value ) {
strictEqual( value, undefined, "pipe fail callback can return undefined/null" ); strictEqual( value, undefined, "then fail callback can return undefined/null" );
}); });
}); });
test( "jQuery.Deferred.pipe - filtering (progress)", function() { test( "jQuery.Deferred.then - filtering (progress)", function() {
expect(3); expect(3);
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.pipe( null, null, function( a, b ) { piped = defer.then( null, null, function( a, b ) {
return a * b; return a * b;
} ), } ),
value1, value1,
...@@ -169,12 +173,12 @@ test( "jQuery.Deferred.pipe - filtering (progress)", function() { ...@@ -169,12 +173,12 @@ test( "jQuery.Deferred.pipe - filtering (progress)", function() {
strictEqual( value3, 6, "result of filter ok" ); strictEqual( value3, 6, "result of filter ok" );
}); });
test( "jQuery.Deferred.pipe - deferred (done)", function() { test( "jQuery.Deferred.then - deferred (done)", function() {
expect(3); expect(3);
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.pipe(function( a, b ) { piped = defer.then(function( a, b ) {
return jQuery.Deferred(function( defer ) { return jQuery.Deferred(function( defer ) {
defer.reject( a * b ); defer.reject( a * b );
}); });
...@@ -199,12 +203,12 @@ test( "jQuery.Deferred.pipe - deferred (done)", function() { ...@@ -199,12 +203,12 @@ test( "jQuery.Deferred.pipe - deferred (done)", function() {
strictEqual( value3, 6, "result of filter ok" ); strictEqual( value3, 6, "result of filter ok" );
}); });
test( "jQuery.Deferred.pipe - deferred (fail)", function() { test( "jQuery.Deferred.then - deferred (fail)", function() {
expect(3); expect(3);
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.pipe( null, function( a, b ) { piped = defer.then( null, function( a, b ) {
return jQuery.Deferred(function( defer ) { return jQuery.Deferred(function( defer ) {
defer.resolve( a * b ); defer.resolve( a * b );
}); });
...@@ -229,12 +233,12 @@ test( "jQuery.Deferred.pipe - deferred (fail)", function() { ...@@ -229,12 +233,12 @@ test( "jQuery.Deferred.pipe - deferred (fail)", function() {
strictEqual( value3, 6, "result of filter ok" ); strictEqual( value3, 6, "result of filter ok" );
}); });
test( "jQuery.Deferred.pipe - deferred (progress)", function() { test( "jQuery.Deferred.then - deferred (progress)", function() {
expect(3); expect(3);
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.pipe( null, null, function( a, b ) { piped = defer.then( null, null, function( a, b ) {
return jQuery.Deferred(function( defer ) { return jQuery.Deferred(function( defer ) {
defer.resolve( a * b ); defer.resolve( a * b );
}); });
...@@ -259,13 +263,13 @@ test( "jQuery.Deferred.pipe - deferred (progress)", function() { ...@@ -259,13 +263,13 @@ test( "jQuery.Deferred.pipe - deferred (progress)", function() {
strictEqual( value3, 6, "result of filter ok" ); strictEqual( value3, 6, "result of filter ok" );
}); });
test( "jQuery.Deferred.pipe - context", function() { test( "jQuery.Deferred.then - context", function() {
expect(4); expect(4);
var context = {}; var context = {};
jQuery.Deferred().resolveWith( context, [ 2 ] ).pipe(function( value ) { jQuery.Deferred().resolveWith( context, [ 2 ] ).then(function( value ) {
return value * 3; return value * 3;
}).done(function( value ) { }).done(function( value ) {
strictEqual( this, context, "custom context correctly propagated" ); strictEqual( this, context, "custom context correctly propagated" );
...@@ -273,7 +277,7 @@ test( "jQuery.Deferred.pipe - context", function() { ...@@ -273,7 +277,7 @@ test( "jQuery.Deferred.pipe - context", function() {
}); });
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.pipe(function( value ) { piped = defer.then(function( value ) {
return value * 3; return value * 3;
}); });
......
...@@ -230,12 +230,13 @@ test("outerWidth()", function() { ...@@ -230,12 +230,13 @@ test("outerWidth()", function() {
jQuery.removeData($div[0], "olddisplay", true); jQuery.removeData($div[0], "olddisplay", true);
}); });
test("child of a hidden elem has accurate inner/outer/Width()/Height() see #9441 #9300", function() { test("child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function() {
expect(8); expect(16);
// setup html // setup html
var $divNormal = jQuery("<div>").css({ width: "100px", height: "100px", border: "10px solid white", padding: "2px", margin: "3px" }), var $divNormal = jQuery("<div>").css({ width: "100px", height: "100px", border: "10px solid white", padding: "2px", margin: "3px" }),
$divChild = $divNormal.clone(), $divChild = $divNormal.clone(),
$divUnconnected = $divNormal.clone(),
$divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body"); $divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body");
$divNormal.appendTo("body"); $divNormal.appendTo("body");
...@@ -250,6 +251,17 @@ test("child of a hidden elem has accurate inner/outer/Width()/Height() see #944 ...@@ -250,6 +251,17 @@ test("child of a hidden elem has accurate inner/outer/Width()/Height() see #944
equal( $divChild.outerHeight(), $divNormal.outerHeight(), "child of a hidden element outerHeight() is wrong see #9441" ); equal( $divChild.outerHeight(), $divNormal.outerHeight(), "child of a hidden element outerHeight() is wrong see #9441" );
equal( $divChild.outerHeight(true), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #9300" ); equal( $divChild.outerHeight(true), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #9300" );
// tests that child div of an unconnected div works the same as a normal div
equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #9441" );
equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #9441" );
equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #9441" );
equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #9300" );
equal( $divUnconnected.height(), $divNormal.height(), "unconnected element height() is wrong see #9441" );
equal( $divUnconnected.innerHeight(), $divNormal.innerHeight(), "unconnected element innerHeight() is wrong see #9441" );
equal( $divUnconnected.outerHeight(), $divNormal.outerHeight(), "unconnected element outerHeight() is wrong see #9441" );
equal( $divUnconnected.outerHeight(true), $divNormal.outerHeight( true ), "unconnected element outerHeight( true ) is wrong see #9300" );
// teardown html // teardown html
$divHiddenParent.remove(); $divHiddenParent.remove();
$divNormal.remove(); $divNormal.remove();
...@@ -278,6 +290,43 @@ test("getting dimensions shouldnt modify runtimeStyle see #9233", function() { ...@@ -278,6 +290,43 @@ test("getting dimensions shouldnt modify runtimeStyle see #9233", function() {
$div.remove(); $div.remove();
}); });
test("box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413", function() {
expect(16);
// setup html
var $divNormal = jQuery("<div>").css({ boxSizing: "border-box", width: "100px", height: "100px", border: "10px solid white", padding: "2px", margin: "3px" }),
$divChild = $divNormal.clone(),
$divUnconnected = $divNormal.clone(),
$divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body");
$divNormal.appendTo("body");
// tests that child div of a hidden div works the same as a normal div
equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #10413" );
equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #10413" );
equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #10413" );
equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #10413" );
equal( $divChild.height(), $divNormal.height(), "child of a hidden element height() is wrong see #10413" );
equal( $divChild.innerHeight(), $divNormal.innerHeight(), "child of a hidden element innerHeight() is wrong see #10413" );
equal( $divChild.outerHeight(), $divNormal.outerHeight(), "child of a hidden element outerHeight() is wrong see #10413" );
equal( $divChild.outerHeight(true), $divNormal.outerHeight( true ), "child of a hidden element outerHeight( true ) is wrong see #10413" );
// tests that child div of an unconnected div works the same as a normal div
equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #10413" );
equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #10413" );
equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #10413" );
equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #10413" );
equal( $divUnconnected.height(), $divNormal.height(), "unconnected element height() is wrong see #10413" );
equal( $divUnconnected.innerHeight(), $divNormal.innerHeight(), "unconnected element innerHeight() is wrong see #10413" );
equal( $divUnconnected.outerHeight(), $divNormal.outerHeight(), "unconnected element outerHeight() is wrong see #10413" );
equal( $divUnconnected.outerHeight(true), $divNormal.outerHeight( true ), "unconnected element outerHeight( true ) is wrong see #10413" );
// teardown html
$divHiddenParent.remove();
$divNormal.remove();
});
test("outerHeight()", function() { test("outerHeight()", function() {
expect(11); expect(11);
......
...@@ -263,6 +263,15 @@ test("animate negative height", function() { ...@@ -263,6 +263,15 @@ test("animate negative height", function() {
}); });
}); });
test("animate negative margin", function() {
expect(1);
stop();
jQuery("#foo").animate({ marginTop: -100 }, 100, function() {
equal( jQuery(this).css("marginTop"), "-100px", "Verify margin." );
start();
});
});
test("animate negative padding", function() { test("animate negative padding", function() {
expect(1); expect(1);
stop(); stop();
......
...@@ -2867,4 +2867,15 @@ test("fixHooks extensions", function() { ...@@ -2867,4 +2867,15 @@ test("fixHooks extensions", function() {
})(); })();
asyncTest("trigger click on checkbox, fires change event", function() {
expect(1);
var check = jQuery("#check2");
check.on( "change", function() {
// get it?
check.off("change");
ok( true, "Change event fired as a result of triggered click" );
start();
}).trigger("click");
});
...@@ -555,6 +555,28 @@ test("html(String) with HTML5 (Bug #6485)", function() { ...@@ -555,6 +555,28 @@ test("html(String) with HTML5 (Bug #6485)", function() {
equal( jQuery("#qunit-fixture").children().children().children().length, 1, "Make sure nested HTML5 elements can hold children." ); equal( jQuery("#qunit-fixture").children().children().children().length, 1, "Make sure nested HTML5 elements can hold children." );
}); });
test("IE8 serialization bug", function () {
expect(2);
var wrapper = jQuery("<div></div>");
wrapper.html("<div></div><article></article>");
equal( wrapper.children("article").length, 1, "HTML5 elements are insertable with .html()");
wrapper.html("<div></div><link></link>");
equal( wrapper.children("link").length, 1, "Link elements are insertable with .html()");
});
test("html() object element #10324", function() {
expect( 1 );
var object = jQuery("<object id='object2'><param name='object2test' value='test'></param></object>?").appendTo("#qunit-fixture"),
clone = object.clone();
equal( clone.html(), object.html(), "html() returns correct innerhtml of cloned object elements" );
});
test("append(xml)", function() { test("append(xml)", function() {
expect( 1 ); expect( 1 );
...@@ -902,7 +924,7 @@ test("insertAfter(String|Element|Array&lt;Element&gt;|jQuery)", function() { ...@@ -902,7 +924,7 @@ test("insertAfter(String|Element|Array&lt;Element&gt;|jQuery)", function() {
}); });
var testReplaceWith = function(val) { var testReplaceWith = function(val) {
expect(21); expect(22);
jQuery("#yahoo").replaceWith(val( "<b id='replace'>buga</b>" )); jQuery("#yahoo").replaceWith(val( "<b id='replace'>buga</b>" ));
ok( jQuery("#replace")[0], "Replace element with string" ); ok( jQuery("#replace")[0], "Replace element with string" );
ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after string" ); ok( !jQuery("#yahoo")[0], "Verify that original element is gone, after string" );
...@@ -963,6 +985,9 @@ var testReplaceWith = function(val) { ...@@ -963,6 +985,9 @@ var testReplaceWith = function(val) {
equal( set[0].nodeName.toLowerCase(), "span", "Replace the disconnected node." ); equal( set[0].nodeName.toLowerCase(), "span", "Replace the disconnected node." );
equal( set.length, 1, "Replace the disconnected node." ); equal( set.length, 1, "Replace the disconnected node." );
// #11338
ok( jQuery("<div>1</div>").replaceWith( val("<span/>") ).is("span"), "#11338, Make sure disconnected node with content is replaced");
var non_existant = jQuery("#does-not-exist").replaceWith( val("<b>should not throw an error</b>") ); var non_existant = jQuery("#does-not-exist").replaceWith( val("<b>should not throw an error</b>") );
equal( non_existant.length, 0, "Length of non existant element." ); equal( non_existant.length, 0, "Length of non existant element." );
...@@ -993,7 +1018,7 @@ test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() { ...@@ -993,7 +1018,7 @@ test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() {
test("replaceWith(Function)", function() { test("replaceWith(Function)", function() {
testReplaceWith(functionReturningObj); testReplaceWith(functionReturningObj);
expect(22); expect(23);
var y = jQuery("#yahoo")[0]; var y = jQuery("#yahoo")[0];
...@@ -1220,11 +1245,9 @@ test("clone(multiple selected options) (Bug #8129)", function() { ...@@ -1220,11 +1245,9 @@ test("clone(multiple selected options) (Bug #8129)", function() {
}); });
if (!isLocal) {
test("clone() on XML nodes", function() { test("clone() on XML nodes", function() {
expect(2); expect(2);
stop(); var xml = createDashboardXML();
jQuery.get("data/dashboard.xml", function (xml) {
var root = jQuery(xml.documentElement).clone(); var root = jQuery(xml.documentElement).clone();
var origTab = jQuery("tab", xml).eq(0); var origTab = jQuery("tab", xml).eq(0);
var cloneTab = jQuery("tab", root).eq(0); var cloneTab = jQuery("tab", root).eq(0);
...@@ -1232,10 +1255,7 @@ test("clone() on XML nodes", function() { ...@@ -1232,10 +1255,7 @@ test("clone() on XML nodes", function() {
cloneTab.text("cloneval"); cloneTab.text("cloneval");
equal(origTab.text(), "origval", "Check original XML node was correctly set"); equal(origTab.text(), "origval", "Check original XML node was correctly set");
equal(cloneTab.text(), "cloneval", "Check cloned XML node was correctly set"); equal(cloneTab.text(), "cloneval", "Check cloned XML node was correctly set");
start();
});
}); });
}
test("clone() on local XML nodes with html5 nodename", function() { test("clone() on local XML nodes with html5 nodename", function() {
expect(2); expect(2);
...@@ -1756,3 +1776,11 @@ test("Guard against exceptions when clearing safeChildNodes", function() { ...@@ -1756,3 +1776,11 @@ test("Guard against exceptions when clearing safeChildNodes", function() {
ok( div && div.jquery, "Created nodes safely, guarded against exceptions on safeChildNodes[ -1 ]" ); ok( div && div.jquery, "Created nodes safely, guarded against exceptions on safeChildNodes[ -1 ]" );
}); });
test("Ensure oldIE creates a new set on appendTo (#8894)", function() {
strictEqual( jQuery("<div/>").clone().addClass("test").appendTo("<div/>").end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.clone" );
strictEqual( jQuery("<div/>").find("p").end().addClass("test").appendTo("<div/>").end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.fn.find" );
strictEqual( jQuery("<div/>").text("test").addClass("test").appendTo("<div/>").end().hasClass("test"), false, "Check jQuery.fn.appendTo after jQuery.fn.text" );
strictEqual( jQuery("<bdi/>").clone().addClass("test").appendTo("<div/>").end().hasClass("test"), false, "Check jQuery.fn.appendTo after clone html5 element" );
strictEqual( jQuery("<p/>").appendTo("<div/>").end().length, jQuery("<p>test</p>").appendTo("<div/>").end().length, "Elements created with createElement and with createDocumentFragment should be treated alike" );
});
...@@ -98,10 +98,6 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -98,10 +98,6 @@ if ( /chrome\/16\.0/i.test(userAgent) ) {
"reliableHiddenOffsets":true, "reliableHiddenOffsets":true,
"ajax":true, "ajax":true,
"cors":true, "cors":true,
"doesNotAddBorder":true,
"doesAddBorderForTableAndCells":false,
"fixedPosition":true,
"subtractsBorderForOverflowNotVisible":false,
"doesNotIncludeMarginInBodyOffset":true "doesNotIncludeMarginInBodyOffset":true
}; };
for ( i in expected ) { for ( i in expected ) {
...@@ -141,10 +137,6 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -141,10 +137,6 @@ if ( /chrome\/16\.0/i.test(userAgent) ) {
"reliableHiddenOffsets":false, "reliableHiddenOffsets":false,
"ajax":true, "ajax":true,
"cors":false, "cors":false,
"doesNotAddBorder":false,
"doesAddBorderForTableAndCells":true,
"fixedPosition":true,
"subtractsBorderForOverflowNotVisible":false,
"doesNotIncludeMarginInBodyOffset":true "doesNotIncludeMarginInBodyOffset":true
}; };
for ( i in expected ) { for ( i in expected ) {
...@@ -164,11 +156,8 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -164,11 +156,8 @@ if ( /chrome\/16\.0/i.test(userAgent) ) {
"cors": false, "cors": false,
"cssFloat": false, "cssFloat": false,
"deleteExpando": false, "deleteExpando": false,
"doesAddBorderForTableAndCells": true,
"doesNotAddBorder": true,
"doesNotIncludeMarginInBodyOffset": true, "doesNotIncludeMarginInBodyOffset": true,
"enctype": true, "enctype": true,
"fixedPosition": true,
"focusinBubbles": true, "focusinBubbles": true,
"getSetAttribute": false, "getSetAttribute": false,
"hrefNormalized": false, "hrefNormalized": false,
...@@ -186,7 +175,6 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -186,7 +175,6 @@ if ( /chrome\/16\.0/i.test(userAgent) ) {
"reliableMarginRight": true, "reliableMarginRight": true,
"shrinkWrapBlocks": false, "shrinkWrapBlocks": false,
"submitBubbles": false, "submitBubbles": false,
"subtractsBorderForOverflowNotVisible": false,
"tbody": false, "tbody": false,
"style": false "style": false
}; };
...@@ -227,10 +215,6 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -227,10 +215,6 @@ if ( /chrome\/16\.0/i.test(userAgent) ) {
"reliableHiddenOffsets":false, "reliableHiddenOffsets":false,
"ajax":true, "ajax":true,
"cors":false, "cors":false,
"doesNotAddBorder":true,
"doesAddBorderForTableAndCells":true,
"fixedPosition":false,
"subtractsBorderForOverflowNotVisible":false,
"doesNotIncludeMarginInBodyOffset":true "doesNotIncludeMarginInBodyOffset":true
}; };
for ( i in expected ) { for ( i in expected ) {
...@@ -270,10 +254,6 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -270,10 +254,6 @@ if ( /chrome\/16\.0/i.test(userAgent) ) {
"reliableHiddenOffsets":true, "reliableHiddenOffsets":true,
"ajax":true, "ajax":true,
"cors":true, "cors":true,
"doesNotAddBorder":true,
"doesAddBorderForTableAndCells":false,
"fixedPosition":true,
"subtractsBorderForOverflowNotVisible":false,
"doesNotIncludeMarginInBodyOffset":true "doesNotIncludeMarginInBodyOffset":true
}; };
for ( i in expected ) { for ( i in expected ) {
...@@ -313,10 +293,6 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -313,10 +293,6 @@ if ( /chrome\/16\.0/i.test(userAgent) ) {
"reliableHiddenOffsets":true, "reliableHiddenOffsets":true,
"ajax":true, "ajax":true,
"cors":true, "cors":true,
"doesNotAddBorder":true,
"doesAddBorderForTableAndCells":true,
"fixedPosition":true,
"subtractsBorderForOverflowNotVisible":false,
"doesNotIncludeMarginInBodyOffset":true "doesNotIncludeMarginInBodyOffset":true
}; };
for ( i in expected ) { for ( i in expected ) {
......
...@@ -370,21 +370,27 @@ test("not(jQuery)", function() { ...@@ -370,21 +370,27 @@ test("not(jQuery)", function() {
}); });
test("has(Element)", function() { test("has(Element)", function() {
expect(2); expect(3);
var obj = jQuery("#qunit-fixture").has(jQuery("#sndp")[0]); var obj = jQuery("#qunit-fixture").has(jQuery("#sndp")[0]);
deepEqual( obj.get(), q("qunit-fixture"), "Keeps elements that have the element as a descendant" ); deepEqual( obj.get(), q("qunit-fixture"), "Keeps elements that have the element as a descendant" );
var detached = jQuery("<a><b><i/></b></a>");
deepEqual( detached.has( detached.find("i")[0] ).get(), detached.get(), "...Even when detached" );
var multipleParent = jQuery("#qunit-fixture, #header").has(jQuery("#sndp")[0]); var multipleParent = jQuery("#qunit-fixture, #header").has(jQuery("#sndp")[0]);
deepEqual( obj.get(), q("qunit-fixture"), "Does not include elements that do not have the element as a descendant" ); deepEqual( obj.get(), q("qunit-fixture"), "Does not include elements that do not have the element as a descendant" );
}); });
test("has(Selector)", function() { test("has(Selector)", function() {
expect(3); expect(4);
var obj = jQuery("#qunit-fixture").has("#sndp"); var obj = jQuery("#qunit-fixture").has("#sndp");
deepEqual( obj.get(), q("qunit-fixture"), "Keeps elements that have any element matching the selector as a descendant" ); deepEqual( obj.get(), q("qunit-fixture"), "Keeps elements that have any element matching the selector as a descendant" );
var detached = jQuery("<a><b><i/></b></a>");
deepEqual( detached.has("i").get(), detached.get(), "...Even when detached" );
var multipleParent = jQuery("#qunit-fixture, #header").has("#sndp"); var multipleParent = jQuery("#qunit-fixture, #header").has("#sndp");
deepEqual( obj.get(), q("qunit-fixture"), "Does not include elements that do not have the element as a descendant" ); deepEqual( obj.get(), q("qunit-fixture"), "Does not include elements that do not have the element as a descendant" );
...@@ -393,11 +399,14 @@ test("has(Selector)", function() { ...@@ -393,11 +399,14 @@ test("has(Selector)", function() {
}); });
test("has(Arrayish)", function() { test("has(Arrayish)", function() {
expect(3); expect(4);
var simple = jQuery("#qunit-fixture").has(jQuery("#sndp")); var simple = jQuery("#qunit-fixture").has(jQuery("#sndp"));
deepEqual( simple.get(), q("qunit-fixture"), "Keeps elements that have any element in the jQuery list as a descendant" ); deepEqual( simple.get(), q("qunit-fixture"), "Keeps elements that have any element in the jQuery list as a descendant" );
var detached = jQuery("<a><b><i/></b></a>");
deepEqual( detached.has( detached.find("i") ).get(), detached.get(), "...Even when detached" );
var multipleParent = jQuery("#qunit-fixture, #header").has(jQuery("#sndp")); var multipleParent = jQuery("#qunit-fixture, #header").has(jQuery("#sndp"));
deepEqual( multipleParent.get(), q("qunit-fixture"), "Does not include elements that do not have an element in the jQuery list as a descendant" ); deepEqual( multipleParent.get(), q("qunit-fixture"), "Does not include elements that do not have an element in the jQuery list as a descendant" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment