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

This reverts commit 532ba250.
parent 532ba250
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 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,8 +12,7 @@ ...@@ -12,8 +12,7 @@
smarttabs: true, smarttabs: true,
predef: [ predef: [
"define", "define",
"DOMParser", "DOMParser"
"WebKitPoint"
], ],
maxerr: 100 maxerr: 100
}; };
......
...@@ -426,8 +426,6 @@ jQuery.extend({ ...@@ -426,8 +426,6 @@ jQuery.extend({
fireGlobals, fireGlobals,
// Loop variable // Loop variable
i, i,
// Default abort message
strAbort = "canceled",
// Fake xhr // Fake xhr
jqXHR = { jqXHR = {
...@@ -473,7 +471,7 @@ jQuery.extend({ ...@@ -473,7 +471,7 @@ jQuery.extend({
// Cancel the request // Cancel the request
abort: function( statusText ) { abort: function( statusText ) {
statusText = statusText || strAbort; statusText = statusText || "abort";
if ( transport ) { if ( transport ) {
transport.abort( statusText ); transport.abort( statusText );
} }
...@@ -611,7 +609,7 @@ jQuery.extend({ ...@@ -611,7 +609,7 @@ jQuery.extend({
} }
} else { } else {
tmp = map[ jqXHR.status ]; tmp = map[ jqXHR.status ];
jqXHR.always( tmp ); jqXHR.then( tmp, tmp );
} }
} }
return this; return this;
...@@ -645,7 +643,7 @@ jQuery.extend({ ...@@ -645,7 +643,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 jqXHR; return false;
} }
// We can fire global events as of now if asked to // We can fire global events as of now if asked to
...@@ -718,14 +716,12 @@ jQuery.extend({ ...@@ -718,14 +716,12 @@ 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 and return // Abort if not done already
return jqXHR.abort(); 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 ] );
...@@ -773,7 +769,7 @@ jQuery.extend({ ...@@ -773,7 +769,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 == null ? "" : value ); value = jQuery.isFunction( value ) ? value() : value;
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
}; };
......
...@@ -356,12 +356,7 @@ jQuery.extend({ ...@@ -356,12 +356,7 @@ 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 if needed // Convert flags from String-formatted to Object-formatted
// (we check in cache first) // (we check in cache first)
flags = typeof flags === "string" ? ( flagsCache[ flags ] || createFlags( flags ) ) : ( flags || {} ); flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
var // Actual callback list var // Actual callback list
list = [], list = [],
......
...@@ -90,6 +90,15 @@ jQuery.fn = jQuery.prototype = { ...@@ -90,6 +90,15 @@ 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?
...@@ -123,7 +132,7 @@ jQuery.fn = jQuery.prototype = { ...@@ -123,7 +132,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;
} }
...@@ -191,7 +200,7 @@ jQuery.fn = jQuery.prototype = { ...@@ -191,7 +200,7 @@ jQuery.fn = jQuery.prototype = {
}, },
toArray: function() { toArray: function() {
return slice.call( this ); return slice.call( this, 0 );
}, },
// Get the Nth element in the matched element set OR // Get the Nth element in the matched element set OR
......
...@@ -13,35 +13,12 @@ var ralpha = /alpha\([^)]*\)/i, ...@@ -13,35 +13,12 @@ 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 ?
...@@ -95,15 +72,10 @@ jQuery.extend({ ...@@ -95,15 +72,10 @@ 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, hooks, var ret, type, origName = jQuery.camelCase( name ),
origName = jQuery.camelCase( name ), style = elem.style, hooks = jQuery.cssHooks[ origName ];
style = elem.style;
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); name = jQuery.cssProps[ origName ] || 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 ) {
...@@ -147,15 +119,12 @@ jQuery.extend({ ...@@ -147,15 +119,12 @@ 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.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); name = jQuery.camelCase( name );
hooks = jQuery.cssHooks[ name ];
// gets hook for the prefixed version name = jQuery.cssProps[ name ] || name;
// 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" ) {
...@@ -272,67 +241,51 @@ curCSS = getComputedStyle || currentStyle; ...@@ -272,67 +241,51 @@ curCSS = getComputedStyle || currentStyle;
function getWidthOrHeight( elem, name, extra ) { 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, var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
i = name === "width" ? 1 : 0, i = name === "width" ? 1 : 0,
len = 4, len = 4;
valueIsBorderBox = true,
isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";
if ( val <= 0 ) {
// Fall back to computed then uncomputed css if necessary
val = curCSS( elem, name );
if ( val < 0 || val == null ) {
val = elem.style[ name ];
}
// Computed unit is not pixels. Stop here and return. if ( val > 0 ) {
if ( rnumnonpx.test(val) ) { if ( extra !== "border" ) {
return val; 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 return val + "px";
// 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 // Fall back to computed then uncomputed css if necessary
val = parseFloat( val ) || 0; val = curCSS( elem, name );
if ( val < 0 || val == null ) {
val = elem.style[ name ];
} }
// determine which box-sizing width we're supposed to be getting // Computed unit is not pixels. Stop here and return.
if ( !extra ) { if ( rnumnonpx.test(val) ) {
extra = isBorderBox ? "border" : "content"; return val;
} }
// if the measurement we need is already represented by the retrieved width // Normalize "", auto, and prepare for extra
// there's no need to augment further val = parseFloat( val ) || 0;
if ( extra !== (valueIsBorderBox ? "border" : "content") ) {
// Add padding, border, margin
if ( extra ) {
for ( ; i < len; i += 2 ) { for ( ; i < len; i += 2 ) {
// both box models exclude margin, so add it if we want it val += parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;
if ( extra === "margin" ) { if ( extra !== "padding" ) {
// we use jQuery.css instead of curCSS here val += parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
// because of the reliableMarginRight CSS hook!
val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ] ) ) || 0;
} }
if ( extra === "margin" ) {
if ( valueIsBorderBox ) { val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ]) ) || 0;
// 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;
}
} }
} }
} }
...@@ -367,7 +320,7 @@ if ( !jQuery.support.opacity ) { ...@@ -367,7 +320,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) || "" ) ?
( 0.01 * parseFloat( RegExp.$1 ) ) + "" : ( parseFloat( RegExp.$1 ) / 100 ) + "" :
computed ? "1" : ""; computed ? "1" : "";
}, },
......
...@@ -6,8 +6,6 @@ var rbrace = /^(?:\{.*\}|\[.*\])$/, ...@@ -6,8 +6,6 @@ var rbrace = /^(?:\{.*\}|\[.*\])$/,
jQuery.extend({ jQuery.extend({
cache: {}, cache: {},
deletedIds: [],
// Please use with caution // Please use with caution
uuid: 0, uuid: 0,
...@@ -61,7 +59,7 @@ jQuery.extend({ ...@@ -61,7 +59,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.deletedIds.pop() || ++jQuery.uuid; elem[ internalKey ] = id = ++jQuery.uuid;
} else { } else {
id = internalKey; id = internalKey;
} }
...@@ -214,8 +212,6 @@ jQuery.extend({ ...@@ -214,8 +212,6 @@ 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,11 +28,15 @@ jQuery.extend({ ...@@ -28,11 +28,15 @@ 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;
}, },
then: function( fnDone, fnFail, fnProgress ) { pipe: function( fnDone, fnFail, fnProgress ) {
return jQuery.Deferred(function( newDefer ) { return jQuery.Deferred(function( newDefer ) {
jQuery.each( { jQuery.each( {
done: [ fnDone, "resolve" ], done: [ fnDone, "resolve" ],
...@@ -46,7 +50,7 @@ jQuery.extend({ ...@@ -46,7 +50,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().done( newDefer.resolve ).fail( newDefer.reject ).progress( newDefer.notify ); returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
} else { } else {
newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
} }
...@@ -70,15 +74,9 @@ jQuery.extend({ ...@@ -70,15 +74,9 @@ jQuery.extend({
return obj; return obj;
} }
}, },
deferred, deferred = promise.promise({}),
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;
...@@ -102,7 +100,7 @@ jQuery.extend({ ...@@ -102,7 +100,7 @@ jQuery.extend({
// Deferred helper // Deferred helper
when: function( firstParam ) { when: function( firstParam ) {
var args = sliceDeferred.call( arguments ), var args = sliceDeferred.call( arguments, 0 ),
i = 0, i = 0,
length = args.length, length = args.length,
pValues = new Array( length ), pValues = new Array( length ),
...@@ -114,7 +112,7 @@ jQuery.extend({ ...@@ -114,7 +112,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 ) : value; args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
if ( !( --count ) ) { if ( !( --count ) ) {
deferred.resolveWith( deferred, args ); deferred.resolveWith( deferred, args );
} }
...@@ -122,14 +120,14 @@ jQuery.extend({ ...@@ -122,14 +120,14 @@ jQuery.extend({
} }
function progressFunc( i ) { function progressFunc( i ) {
return function( value ) { return function( value ) {
pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments ) : value; pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : 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().done( resolveFunc(i) ).fail( deferred.reject ).progress( progressFunc(i) ); args[ i ].promise().then( resolveFunc(i), deferred.reject, 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, "content" ); orig = jQuery.css( elem, type );
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.style( elem, type, value ); jQuery( elem ).css( type, value );
}, type, value, arguments.length, null ); }, type, value, arguments.length, null );
}; };
}); });
......
...@@ -4,7 +4,6 @@ var elemdisplay = {}, ...@@ -4,7 +4,6 @@ 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
...@@ -637,8 +636,8 @@ jQuery.extend( jQuery.fx, { ...@@ -637,8 +636,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 ( !rMarginProp.test( prop ) ) { if ( prop.indexOf( "margin" ) ) {
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, eventType, handleObj; j, events, special, handle, eventType, handleObj;
if ( !elemData || !(events = elemData.events) ) { if ( !elemData || !(events = elemData.events) ) {
return; return;
...@@ -213,11 +213,14 @@ jQuery.event = { ...@@ -213,11 +213,14 @@ 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 ) ) {
delete elemData.handle; handle = 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", true ); jQuery.removeData( elem, [ "events", "handle" ], true );
} }
}, },
...@@ -386,7 +389,7 @@ jQuery.event = { ...@@ -386,7 +389,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 ), args = [].slice.call( arguments, 0 ),
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 = [],
...@@ -633,17 +636,8 @@ jQuery.removeEvent = document.removeEventListener ? ...@@ -633,17 +636,8 @@ 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 );
} }
}; };
...@@ -825,9 +819,8 @@ if ( !jQuery.support.changeBubbles ) { ...@@ -825,9 +819,8 @@ 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;
...@@ -1074,3 +1067,4 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl ...@@ -1074,3 +1067,4 @@ 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 ) { getOffset = function( elem, doc, docElem, box ) {
var box;
try { try {
box = elem.getBoundingClientRect(); box = elem.getBoundingClientRect();
} catch(e) {} } catch(e) {}
...@@ -30,12 +29,56 @@ if ( "getBoundingClientRect" in document.documentElement ) { ...@@ -30,12 +29,56 @@ if ( "getBoundingClientRect" in document.documentElement ) {
} else { } else {
getOffset = function( elem, doc, docElem ) { getOffset = function( elem, doc, docElem ) {
if ( !jQuery.contains( docElem, elem ) ) { var computedStyle,
return { top: 0, left: 0 }; offsetParent = elem.offsetParent,
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;
}
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 );
} }
var point = getWindow( doc ).webkitConvertPointFromNodeToPage( elem, new WebKitPoint( 0, 0 ) );
return { top: point.y, left: point.x };
return { top: top, left: left };
}; };
} }
......
...@@ -91,8 +91,7 @@ jQuery.support = (function() { ...@@ -91,8 +91,7 @@ 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
...@@ -179,9 +178,9 @@ jQuery.support = (function() { ...@@ -179,9 +178,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, offsetSupport, marginDiv, var container, outer, inner, table, td, offsetSupport,
conMarginTop = 1, marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight,
boxSizingPrefixes = [ "", "-moz-", "-webkit-", "" ], paddingMarginBorderVisibility, paddingMarginBorder,
body = document.getElementsByTagName("body")[0]; body = document.getElementsByTagName("body")[0];
if ( !body ) { if ( !body ) {
...@@ -189,8 +188,17 @@ jQuery.support = (function() { ...@@ -189,8 +188,17 @@ 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 = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; container.style.cssText = paddingMarginBorderVisibility + "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
...@@ -204,7 +212,7 @@ jQuery.support = (function() { ...@@ -204,7 +212,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='padding:0;margin:0;border:0;display:none'></td><td>t</td></tr></table>"; div.innerHTML = "<table><tr><td style='" + paddingMarginBorder + "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 );
...@@ -252,17 +260,35 @@ jQuery.support = (function() { ...@@ -252,17 +260,35 @@ jQuery.support = (function() {
support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
} }
div.style.cssText = boxSizingPrefixes.join("box-sizing:border-box;") + "border:1px;width:4px;padding:1px;display:block;margin-top:1%;"; div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility;
support.boxSizing = ( div.offsetWidth === 4 ); div.innerHTML = html;
if ( window.getComputedStyle ) {
support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px"; outer = div.firstChild;
support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%"; inner = outer.firstChild;
} td = outer.nextSibling.firstChild.firstChild;
offsetSupport = { offsetSupport = {
doesNotIncludeMarginInBodyOffset: ( body.offsetTop !== conMarginTop ) doesNotAddBorder: ( inner.offsetTop !== 5 ),
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, this ); var targets = jQuery( target );
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,
...@@ -47,53 +45,6 @@ function t(a,b,c) { ...@@ -47,53 +45,6 @@ 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 ) {
...@@ -208,4 +159,4 @@ function url(value) { ...@@ -208,4 +159,4 @@ function url(value) {
window.start = function() { window.start = function() {
oldStart(); oldStart();
}; };
})(); })();
\ No newline at end of file
...@@ -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);
jQuery.ajax({ var request = 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,14 +872,13 @@ test("jQuery.ajax - beforeSend, cancel request (#2688)", function() { ...@@ -872,14 +872,13 @@ 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);
jQuery.ajax({ var request = 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" );
...@@ -894,9 +893,8 @@ test("jQuery.ajax - beforeSend, cancel request manually", function() { ...@@ -894,9 +893,8 @@ 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;
...@@ -962,16 +960,13 @@ test("serialize()", function() { ...@@ -962,16 +960,13 @@ test("serialize()", function() {
}); });
test("jQuery.param()", function() { test("jQuery.param()", function() {
expect(22); expect(21);
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" );
...@@ -985,13 +980,13 @@ test("jQuery.param()", function() { ...@@ -985,13 +980,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]=&i[]=10&i[]=11&j=true&k=false&l[]=&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]=undefined&i[]=10&i[]=11&j=true&k=false&l[]=undefined&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=&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=undefined&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." );
...@@ -1016,16 +1011,16 @@ test("jQuery.param()", function() { ...@@ -1016,16 +1011,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=&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=undefined&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]=&i[]=10&i[]=11&j=true&k=false&l[]=&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]=undefined&i[]=10&i[]=11&j=true&k=false&l[]=undefined&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" );
params = { param1: null }; params = { param1: null };
equal( jQuery.param(params,false), "param1=", "Make sure that null params aren't traversed." ); equal( jQuery.param(params,false), "param1=null", "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" );
...@@ -2114,14 +2109,13 @@ test( "jQuery.ajax - Context with circular references (#9887)", 2, function () { ...@@ -2114,14 +2109,13 @@ test( "jQuery.ajax - Context with circular references (#9887)", 2, function () {
context = {}; context = {};
context.field = context; context.field = context;
try { try {
jQuery.ajax( "non-existing", { success = !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" );
}); });
...@@ -2321,14 +2315,12 @@ test("jQuery.ajax - abort in prefilter", function() { ...@@ -2321,14 +2315,12 @@ test("jQuery.ajax - abort in prefilter", function() {
} }
}); });
jQuery.ajax({ strictEqual( jQuery.ajax({
abortInPrefilter: true, abortInPrefilter: true,
error: function() { error: function() {
ok( false, "error callback called" ); ok( false, "error callback called" );
} }
}).fail(function( _, reason ) { }), false, "Request was properly aborted early by the prefilter" );
strictEqual( reason, 'canceled', "Request aborted by the prefilter must fail with 'canceled' status text" );
});
}); });
......
...@@ -127,13 +127,18 @@ test("attr(String)", function() { ...@@ -127,13 +127,18 @@ 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)" );
}); });
test("attr(String) in XML Files", function() { if ( !isLocal ) {
expect(3); test("attr(String) in XML Files", function() {
var xml = createDashboardXML(); expect(3);
equal( jQuery( "locations", xml ).attr("class"), "foo", "Check class attribute in XML document" ); stop();
equal( jQuery( "location", xml ).attr("for"), "bar", "Check for attribute in XML document" ); jQuery.get("data/dashboard.xml", function( xml ) {
equal( jQuery( "location", xml ).attr("checked"), "different", "Check that hooks are not attached 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("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);
...@@ -387,16 +392,21 @@ test("attr(jquery_method)", function(){ ...@@ -387,16 +392,21 @@ test("attr(jquery_method)", function(){
equal( elem.style.paddingRight, "1px", "attr({...})"); equal( elem.style.paddingRight, "1px", "attr({...})");
}); });
test("attr(String, Object) - Loaded via XML document", function() { if ( !isLocal ) {
expect(2); test("attr(String, Object) - Loaded via XML document", function() {
var xml = createDashboardXML(); expect(2);
var titles = []; stop();
jQuery( "tab", xml ).each(function() { jQuery.get("data/dashboard.xml", function( xml ) {
titles.push( jQuery(this).attr("title") ); var titles = [];
jQuery( "tab", xml ).each(function() {
titles.push( jQuery(this).attr("title") );
});
equal( titles[0], "Location", "attr() in XML context: Check first title" );
equal( titles[1], "Users", "attr() in XML context: Check second title" );
start();
});
}); });
equal( titles[0], "Location", "attr() in XML context: Check first title" ); }
equal( titles[1], "Users", "attr() in XML context: Check second title" );
});
test("attr('tabindex')", function() { test("attr('tabindex')", function() {
expect(8); expect(8);
...@@ -1182,16 +1192,3 @@ test("coords returns correct values in IE6/IE7, see #10828", function() { ...@@ -1182,16 +1192,3 @@ 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,171 +33,149 @@ var output, ...@@ -33,171 +33,149 @@ var output,
} }
}; };
function showFlags( flags ) { jQuery.each( tests, function( flags, resultString ) {
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 ) { jQuery.each( filters, function( filterLabel, filter ) {
var objectFlags = {}; test( "jQuery.Callbacks( \"" + flags + "\" ) - " + filterLabel, function() {
jQuery.each( strFlags.split( " " ), function() { expect( 20 );
if ( this.length ) {
objectFlags[ this ] = true;
}
});
jQuery.each( filters, function( filterLabel, filter ) { // Give qunit a little breathing room
stop();
setTimeout( start, 0 );
var cblist;
results = resultString.split( /\s+/ );
jQuery.each( { "string": strFlags, "object": objectFlags }, function( flagsTypes, flags ) { // Basic binding and firing
output = "X";
test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function() { cblist = jQuery.Callbacks( flags );
cblist.add(function( str ) {
expect( 20 ); output += str;
});
// Give qunit a little breathing room cblist.fire( "A" );
stop(); strictEqual( output, "XA", "Basic binding and firing" );
setTimeout( start, 0 ); strictEqual( cblist.fired(), true, ".fired() detects firing" );
output = "X";
var cblist; cblist.disable();
results = resultString.split( /\s+/ ); cblist.add(function( str ) {
output += str;
// Basic binding and firing });
output = "X"; strictEqual( output, "X", "Adding a callback after disabling" );
cblist = jQuery.Callbacks( flags ); cblist.fire( "A" );
cblist.add(function( str ) { strictEqual( output, "X", "Firing after disabling" );
output += str;
}); // Basic binding and firing (context, arguments)
cblist.fire( "A" ); output = "X";
strictEqual( output, "XA", "Basic binding and firing" ); cblist = jQuery.Callbacks( flags );
strictEqual( cblist.fired(), true, ".fired() detects firing" ); cblist.add(function() {
output = "X"; equal( this, window, "Basic binding and firing (context)" );
cblist.disable(); output += Array.prototype.join.call( arguments, "" );
cblist.add(function( str ) { });
output += str; cblist.fireWith( window, [ "A", "B" ] );
}); strictEqual( output, "XAB", "Basic binding and firing (arguments)" );
strictEqual( output, "X", "Adding a callback after disabling" );
cblist.fire( "A" ); // fireWith with no arguments
strictEqual( output, "X", "Firing after disabling" ); output = "";
cblist = jQuery.Callbacks( flags );
// Basic binding and firing (context, arguments) cblist.add(function() {
output = "X"; equal( this, window, "fireWith with no arguments (context is window)" );
cblist = jQuery.Callbacks( flags ); strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" );
cblist.add(function() { });
equal( this, window, "Basic binding and firing (context)" ); cblist.fireWith();
output += Array.prototype.join.call( arguments, "" );
}); // Basic binding, removing and firing
cblist.fireWith( window, [ "A", "B" ] ); output = "X";
strictEqual( output, "XAB", "Basic binding and firing (arguments)" ); cblist = jQuery.Callbacks( flags );
cblist.add( outputA, outputB, outputC );
// fireWith with no arguments cblist.remove( outputB, outputC );
output = ""; cblist.fire();
cblist = jQuery.Callbacks( flags ); strictEqual( output, "XA", "Basic binding, removing and firing" );
cblist.add(function() {
equal( this, window, "fireWith with no arguments (context is window)" ); // Empty
strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" ); output = "X";
}); cblist = jQuery.Callbacks( flags );
cblist.fireWith(); cblist.add( outputA );
cblist.add( outputB );
// Basic binding, removing and firing cblist.add( outputC );
output = "X"; cblist.empty();
cblist = jQuery.Callbacks( flags ); cblist.fire();
cblist.add( outputA, outputB, outputC ); strictEqual( output, "X", "Empty" );
cblist.remove( outputB, outputC );
cblist.fire(); // Locking
strictEqual( output, "XA", "Basic binding, removing and firing" ); output = "X";
cblist = jQuery.Callbacks( flags );
// Empty cblist.add( function( str ) {
output = "X"; output += str;
cblist = jQuery.Callbacks( flags ); });
cblist.add( outputA ); cblist.lock();
cblist.add( outputB ); cblist.add( function( str ) {
output += str;
});
cblist.fire( "A" );
cblist.add( function( str ) {
output += str;
});
strictEqual( output, "X", "Lock early" );
// Ordering
output = "X";
cblist = jQuery.Callbacks( flags );
cblist.add( function() {
cblist.add( outputC ); cblist.add( outputC );
cblist.empty(); outputA();
cblist.fire(); }, outputB );
strictEqual( output, "X", "Empty" ); cblist.fire();
strictEqual( output, results.shift(), "Proper ordering" );
// Locking
output = "X"; // Add and fire again
cblist = jQuery.Callbacks( flags ); output = "X";
cblist.add( function( str ) { cblist.add( function() {
output += str;
});
cblist.lock();
cblist.add( function( str ) {
output += str;
});
cblist.fire( "A" );
cblist.add( function( str ) {
output += str;
});
strictEqual( output, "X", "Lock early" );
// Ordering
output = "X";
cblist = jQuery.Callbacks( flags );
cblist.add( function() {
cblist.add( outputC );
outputA();
}, outputB );
cblist.fire();
strictEqual( output, results.shift(), "Proper ordering" );
// Add and fire again
output = "X";
cblist.add( function() {
cblist.add( outputC );
outputA();
}, outputB );
strictEqual( output, results.shift(), "Add after fire" );
output = "X";
cblist.fire();
strictEqual( output, results.shift(), "Fire again" );
// Multiple fire
output = "X";
cblist = jQuery.Callbacks( flags );
cblist.add( function( str ) {
output += str;
} );
cblist.fire( "A" );
strictEqual( output, "XA", "Multiple fire (first fire)" );
output = "X";
cblist.add( function( str ) {
output += str;
} );
strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
output = "X";
cblist.fire( "B" );
strictEqual( output, results.shift(), "Multiple fire (second fire)" );
output = "X";
cblist.add( function( str ) {
output += str;
} );
strictEqual( output, results.shift(), "Multiple fire (second new callback)" );
// Return false
output = "X";
cblist = jQuery.Callbacks( flags );
cblist.add( outputA, function() { return false; }, outputB );
cblist.add( outputA );
cblist.fire();
strictEqual( output, results.shift(), "Callback returning false" );
// Add another callback (to control lists with memory do not fire anymore)
output = "X";
cblist.add( outputC ); cblist.add( outputC );
strictEqual( output, results.shift(), "Adding a callback after one returned false" ); outputA();
}, outputB );
strictEqual( output, results.shift(), "Add after fire" );
output = "X";
cblist.fire();
strictEqual( output, results.shift(), "Fire again" );
// Multiple fire
output = "X";
cblist = jQuery.Callbacks( flags );
cblist.add( function( str ) {
output += str;
} );
cblist.fire( "A" );
strictEqual( output, "XA", "Multiple fire (first fire)" );
output = "X";
cblist.add( function( str ) {
output += str;
} );
strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
output = "X";
cblist.fire( "B" );
strictEqual( output, results.shift(), "Multiple fire (second fire)" );
output = "X";
cblist.add( function( str ) {
output += str;
} );
strictEqual( output, results.shift(), "Multiple fire (second new callback)" );
// Return false
output = "X";
cblist = jQuery.Callbacks( flags );
cblist.add( outputA, function() { return false; }, outputB );
cblist.add( outputA );
cblist.fire();
strictEqual( output, results.shift(), "Callback returning false" );
// Add another callback (to control lists with memory do not fire anymore)
output = "X";
cblist.add( outputC );
strictEqual( output, results.shift(), "Adding a callback after one returned false" );
});
}); });
}); });
}); });
......
...@@ -547,16 +547,21 @@ test("XSS via location.hash", function() { ...@@ -547,16 +547,21 @@ 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);
var xml = createDashboardXML(); stop();
ok( jQuery.isXMLDoc( xml ), "XML document" ); jQuery.get("data/dashboard.xml", function(xml) {
ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" ); ok( jQuery.isXMLDoc( xml ), "XML document" );
ok( jQuery.isXMLDoc( jQuery("tab", xml)[0] ), "XML Tab Element" ); ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" );
ok( jQuery.isXMLDoc( jQuery("tab", xml)[0] ), "XML Tab Element" );
start();
});
}); });
}
test("isWindow", function() { test("isWindow", function() {
expect( 14 ); expect( 14 );
...@@ -633,16 +638,20 @@ test("jQuery('html', context)", function() { ...@@ -633,16 +638,20 @@ 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();
var xml = createDashboardXML(); jQuery.get("data/dashboard.xml", function(xml) {
// 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,18 +555,6 @@ test("outerWidth(true) and css('margin') returning % instead of px in Webkit, se ...@@ -555,18 +555,6 @@ 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,6 +184,9 @@ test(".data()", function() { ...@@ -184,6 +184,9 @@ 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" );
...@@ -195,6 +198,9 @@ test(".data()", function() { ...@@ -195,6 +198,9 @@ 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,36 +8,32 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { ...@@ -8,36 +8,32 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
test("jQuery.Deferred" + withNew, function() { test("jQuery.Deferred" + withNew, function() {
expect( 23 ); expect( 22 );
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)" );
}).fail(function() { }, 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().done(function() { createDeferred().reject().then( function() {
ok( false , "Success on reject" ); ok( false , "Success on reject" );
}).fail(function() { }, 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" );
}).done( function( value ) { }).then( function( value ) {
strictEqual( value , "done" , "Passed function executed" ); strictEqual( value , "done" , "Passed function executed" );
}); });
...@@ -62,7 +58,7 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { ...@@ -62,7 +58,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 always".split( " " ), var methods = "resolve reject notify resolveWith rejectWith notifyWith done fail progress then always".split( " " ),
defer = jQuery.Deferred(); defer = jQuery.Deferred();
expect( methods.length ); expect( methods.length );
...@@ -73,12 +69,12 @@ test( "jQuery.Deferred - chainability", function() { ...@@ -73,12 +69,12 @@ test( "jQuery.Deferred - chainability", function() {
}); });
}); });
test( "jQuery.Deferred.then - filtering (done)", function() { test( "jQuery.Deferred.pipe - filtering (done)", function() {
expect(4); expect(4);
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.then(function( a, b ) { piped = defer.pipe(function( a, b ) {
return a * b; return a * b;
}), }),
value1, value1,
...@@ -100,21 +96,21 @@ test( "jQuery.Deferred.then - filtering (done)", function() { ...@@ -100,21 +96,21 @@ test( "jQuery.Deferred.then - 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().then(function() { jQuery.Deferred().reject().pipe(function() {
ok( false, "then should not be called on reject" ); ok( false, "pipe should not be called on reject" );
}); });
jQuery.Deferred().resolve().then( jQuery.noop ).done(function( value ) { jQuery.Deferred().resolve().pipe( jQuery.noop ).done(function( value ) {
strictEqual( value, undefined, "then done callback can return undefined/null" ); strictEqual( value, undefined, "pipe done callback can return undefined/null" );
}); });
}); });
test( "jQuery.Deferred.then - filtering (fail)", function() { test( "jQuery.Deferred.pipe - filtering (fail)", function() {
expect(4); expect(4);
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.then( null, function( a, b ) { piped = defer.pipe( null, function( a, b ) {
return a * b; return a * b;
} ), } ),
value1, value1,
...@@ -136,21 +132,21 @@ test( "jQuery.Deferred.then - filtering (fail)", function() { ...@@ -136,21 +132,21 @@ test( "jQuery.Deferred.then - 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().then( null, function() { jQuery.Deferred().resolve().pipe( null, function() {
ok( false, "then should not be called on resolve" ); ok( false, "pipe should not be called on resolve" );
} ); } );
jQuery.Deferred().reject().then( null, jQuery.noop ).fail(function( value ) { jQuery.Deferred().reject().pipe( null, jQuery.noop ).fail(function( value ) {
strictEqual( value, undefined, "then fail callback can return undefined/null" ); strictEqual( value, undefined, "pipe fail callback can return undefined/null" );
}); });
}); });
test( "jQuery.Deferred.then - filtering (progress)", function() { test( "jQuery.Deferred.pipe - filtering (progress)", function() {
expect(3); expect(3);
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.then( null, null, function( a, b ) { piped = defer.pipe( null, null, function( a, b ) {
return a * b; return a * b;
} ), } ),
value1, value1,
...@@ -173,12 +169,12 @@ test( "jQuery.Deferred.then - filtering (progress)", function() { ...@@ -173,12 +169,12 @@ test( "jQuery.Deferred.then - filtering (progress)", function() {
strictEqual( value3, 6, "result of filter ok" ); strictEqual( value3, 6, "result of filter ok" );
}); });
test( "jQuery.Deferred.then - deferred (done)", function() { test( "jQuery.Deferred.pipe - deferred (done)", function() {
expect(3); expect(3);
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.then(function( a, b ) { piped = defer.pipe(function( a, b ) {
return jQuery.Deferred(function( defer ) { return jQuery.Deferred(function( defer ) {
defer.reject( a * b ); defer.reject( a * b );
}); });
...@@ -203,12 +199,12 @@ test( "jQuery.Deferred.then - deferred (done)", function() { ...@@ -203,12 +199,12 @@ test( "jQuery.Deferred.then - deferred (done)", function() {
strictEqual( value3, 6, "result of filter ok" ); strictEqual( value3, 6, "result of filter ok" );
}); });
test( "jQuery.Deferred.then - deferred (fail)", function() { test( "jQuery.Deferred.pipe - deferred (fail)", function() {
expect(3); expect(3);
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.then( null, function( a, b ) { piped = defer.pipe( null, function( a, b ) {
return jQuery.Deferred(function( defer ) { return jQuery.Deferred(function( defer ) {
defer.resolve( a * b ); defer.resolve( a * b );
}); });
...@@ -233,12 +229,12 @@ test( "jQuery.Deferred.then - deferred (fail)", function() { ...@@ -233,12 +229,12 @@ test( "jQuery.Deferred.then - deferred (fail)", function() {
strictEqual( value3, 6, "result of filter ok" ); strictEqual( value3, 6, "result of filter ok" );
}); });
test( "jQuery.Deferred.then - deferred (progress)", function() { test( "jQuery.Deferred.pipe - deferred (progress)", function() {
expect(3); expect(3);
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.then( null, null, function( a, b ) { piped = defer.pipe( null, null, function( a, b ) {
return jQuery.Deferred(function( defer ) { return jQuery.Deferred(function( defer ) {
defer.resolve( a * b ); defer.resolve( a * b );
}); });
...@@ -263,13 +259,13 @@ test( "jQuery.Deferred.then - deferred (progress)", function() { ...@@ -263,13 +259,13 @@ test( "jQuery.Deferred.then - deferred (progress)", function() {
strictEqual( value3, 6, "result of filter ok" ); strictEqual( value3, 6, "result of filter ok" );
}); });
test( "jQuery.Deferred.then - context", function() { test( "jQuery.Deferred.pipe - context", function() {
expect(4); expect(4);
var context = {}; var context = {};
jQuery.Deferred().resolveWith( context, [ 2 ] ).then(function( value ) { jQuery.Deferred().resolveWith( context, [ 2 ] ).pipe(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" );
...@@ -277,7 +273,7 @@ test( "jQuery.Deferred.then - context", function() { ...@@ -277,7 +273,7 @@ test( "jQuery.Deferred.then - context", function() {
}); });
var defer = jQuery.Deferred(), var defer = jQuery.Deferred(),
piped = defer.then(function( value ) { piped = defer.pipe(function( value ) {
return value * 3; return value * 3;
}); });
......
...@@ -230,13 +230,12 @@ test("outerWidth()", function() { ...@@ -230,13 +230,12 @@ test("outerWidth()", function() {
jQuery.removeData($div[0], "olddisplay", true); jQuery.removeData($div[0], "olddisplay", true);
}); });
test("child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function() { test("child of a hidden elem has accurate inner/outer/Width()/Height() see #9441 #9300", function() {
expect(16); expect(8);
// 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");
...@@ -251,17 +250,6 @@ test("child of a hidden elem (or unconnected node) has accurate inner/outer/Widt ...@@ -251,17 +250,6 @@ test("child of a hidden elem (or unconnected node) has accurate inner/outer/Widt
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();
...@@ -290,43 +278,6 @@ test("getting dimensions shouldnt modify runtimeStyle see #9233", function() { ...@@ -290,43 +278,6 @@ 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,15 +263,6 @@ test("animate negative height", function() { ...@@ -263,15 +263,6 @@ 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,15 +2867,4 @@ test("fixHooks extensions", function() { ...@@ -2867,15 +2867,4 @@ 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,28 +555,6 @@ test("html(String) with HTML5 (Bug #6485)", function() { ...@@ -555,28 +555,6 @@ 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 );
...@@ -924,7 +902,7 @@ test("insertAfter(String|Element|Array&lt;Element&gt;|jQuery)", function() { ...@@ -924,7 +902,7 @@ test("insertAfter(String|Element|Array&lt;Element&gt;|jQuery)", function() {
}); });
var testReplaceWith = function(val) { var testReplaceWith = function(val) {
expect(22); expect(21);
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" );
...@@ -985,9 +963,6 @@ var testReplaceWith = function(val) { ...@@ -985,9 +963,6 @@ 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." );
...@@ -1018,7 +993,7 @@ test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() { ...@@ -1018,7 +993,7 @@ test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() {
test("replaceWith(Function)", function() { test("replaceWith(Function)", function() {
testReplaceWith(functionReturningObj); testReplaceWith(functionReturningObj);
expect(23); expect(22);
var y = jQuery("#yahoo")[0]; var y = jQuery("#yahoo")[0];
...@@ -1245,17 +1220,22 @@ test("clone(multiple selected options) (Bug #8129)", function() { ...@@ -1245,17 +1220,22 @@ 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);
var xml = createDashboardXML(); stop();
var root = jQuery(xml.documentElement).clone(); jQuery.get("data/dashboard.xml", function (xml) {
var origTab = jQuery("tab", xml).eq(0); var root = jQuery(xml.documentElement).clone();
var cloneTab = jQuery("tab", root).eq(0); var origTab = jQuery("tab", xml).eq(0);
origTab.text("origval"); var cloneTab = jQuery("tab", root).eq(0);
cloneTab.text("cloneval"); origTab.text("origval");
equal(origTab.text(), "origval", "Check original XML node was correctly set"); cloneTab.text("cloneval");
equal(cloneTab.text(), "cloneval", "Check cloned 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");
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);
...@@ -1775,12 +1755,4 @@ test("Guard against exceptions when clearing safeChildNodes", function() { ...@@ -1775,12 +1755,4 @@ test("Guard against exceptions when clearing safeChildNodes", function() {
} catch(e) {} } catch(e) {}
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 ]" );
}); });
\ No newline at end of file
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,6 +98,10 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -98,6 +98,10 @@ 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 ) {
...@@ -137,6 +141,10 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -137,6 +141,10 @@ 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 ) {
...@@ -156,8 +164,11 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -156,8 +164,11 @@ 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,
...@@ -175,6 +186,7 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -175,6 +186,7 @@ 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
}; };
...@@ -215,6 +227,10 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -215,6 +227,10 @@ 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 ) {
...@@ -254,6 +270,10 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -254,6 +270,10 @@ 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 ) {
...@@ -293,6 +313,10 @@ if ( /chrome\/16\.0/i.test(userAgent) ) { ...@@ -293,6 +313,10 @@ 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,27 +370,21 @@ test("not(jQuery)", function() { ...@@ -370,27 +370,21 @@ test("not(jQuery)", function() {
}); });
test("has(Element)", function() { test("has(Element)", function() {
expect(3); expect(2);
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(4); expect(3);
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" );
...@@ -399,14 +393,11 @@ test("has(Selector)", function() { ...@@ -399,14 +393,11 @@ test("has(Selector)", function() {
}); });
test("has(Arrayish)", function() { test("has(Arrayish)", function() {
expect(4); expect(3);
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