Commit 16312c6b authored by Dave Methvin's avatar Dave Methvin

Merge branch 'master' of github.com:jquery/jquery into fix-8790a-quicker-trigger

parents 235080e1 d274b7b9
This diff is collapsed.
This diff is collapsed.
...@@ -95,7 +95,7 @@ function addToPrefiltersOrTransports( structure ) { ...@@ -95,7 +95,7 @@ function addToPrefiltersOrTransports( structure ) {
}; };
} }
//Base inspection function for prefilters and transports // Base inspection function for prefilters and transports
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
dataType /* internal */, inspected /* internal */ ) { dataType /* internal */, inspected /* internal */ ) {
...@@ -389,6 +389,7 @@ jQuery.extend({ ...@@ -389,6 +389,7 @@ jQuery.extend({
ifModifiedKey, ifModifiedKey,
// Headers (they are sent all at once) // Headers (they are sent all at once)
requestHeaders = {}, requestHeaders = {},
requestHeadersNames = {},
// Response headers // Response headers
responseHeadersString, responseHeadersString,
responseHeaders, responseHeaders,
...@@ -412,7 +413,9 @@ jQuery.extend({ ...@@ -412,7 +413,9 @@ jQuery.extend({
// Caches the header // Caches the header
setRequestHeader: function( name, value ) { setRequestHeader: function( name, value ) {
if ( !state ) { if ( !state ) {
requestHeaders[ name.toLowerCase() ] = { n: name, v: value }; var lname = name.toLowerCase();
name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
requestHeaders[ name ] = value;
} }
return this; return this;
}, },
......
(function( jQuery ) { (function( jQuery ) {
var // #5280: next active xhr id and list of active xhrs' callbacks var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
xhrId = jQuery.now(), xhrOnUnloadAbort = window.ActiveXObject ? function() {
xhrCallbacks,
// XHR used to determine supports properties
testXHR;
// #5280: Internet Explorer will keep connections alive if we don't abort on unload
function xhrOnUnloadAbort() {
jQuery( window ).unload(function() {
// Abort all pending requests // Abort all pending requests
for ( var key in xhrCallbacks ) { for ( var key in xhrCallbacks ) {
xhrCallbacks[ key ]( 0, 1 ); xhrCallbacks[ key ]( 0, 1 );
} }
}); } : false,
} xhrId = 0,
xhrCallbacks;
// Functions to create xhrs // Functions to create xhrs
function createStandardXHR() { function createStandardXHR() {
...@@ -45,15 +38,13 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject ? ...@@ -45,15 +38,13 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject ?
// For all other browsers, use the standard XMLHttpRequest object // For all other browsers, use the standard XMLHttpRequest object
createStandardXHR; createStandardXHR;
// Test if we can create an xhr object // Determine support properties
testXHR = jQuery.ajaxSettings.xhr(); (function( xhr ) {
jQuery.support.ajax = !!testXHR; jQuery.extend( jQuery.support, {
ajax: !!xhr,
// Does this browser support crossDomain XHR requests cors: !!xhr && ( "withCredentials" in xhr )
jQuery.support.cors = testXHR && ( "withCredentials" in testXHR ); });
})( jQuery.ajaxSettings.xhr() );
// No need for the temporary xhr anymore
testXHR = undefined;
// Create transport if the browser can provide an xhr // Create transport if the browser can provide an xhr
if ( jQuery.support.ajax ) { if ( jQuery.support.ajax ) {
...@@ -104,7 +95,7 @@ if ( jQuery.support.ajax ) { ...@@ -104,7 +95,7 @@ if ( jQuery.support.ajax ) {
// Need an extra try/catch for cross domain requests in Firefox 3 // Need an extra try/catch for cross domain requests in Firefox 3
try { try {
for ( i in headers ) { for ( i in headers ) {
xhr.setRequestHeader( headers[ i ].n, headers[ i ].v ); xhr.setRequestHeader( i, headers[ i ] );
} }
} catch( _ ) {} } catch( _ ) {}
...@@ -136,7 +127,9 @@ if ( jQuery.support.ajax ) { ...@@ -136,7 +127,9 @@ if ( jQuery.support.ajax ) {
// Do not keep as active anymore // Do not keep as active anymore
if ( handle ) { if ( handle ) {
xhr.onreadystatechange = jQuery.noop; xhr.onreadystatechange = jQuery.noop;
delete xhrCallbacks[ handle ]; if ( xhrOnUnloadAbort ) {
delete xhrCallbacks[ handle ];
}
} }
// If it's an abort // If it's an abort
...@@ -197,15 +190,18 @@ if ( jQuery.support.ajax ) { ...@@ -197,15 +190,18 @@ if ( jQuery.support.ajax ) {
if ( !s.async || xhr.readyState === 4 ) { if ( !s.async || xhr.readyState === 4 ) {
callback(); callback();
} else { } else {
// Create the active xhrs callbacks list if needed handle = ++xhrId;
// and attach the unload handler if ( xhrOnUnloadAbort ) {
if ( !xhrCallbacks ) { // Create the active xhrs callbacks list if needed
xhrCallbacks = {}; // and attach the unload handler
xhrOnUnloadAbort(); if ( !xhrCallbacks ) {
xhrCallbacks = {};
jQuery( window ).unload( xhrOnUnloadAbort );
}
// Add to list of active xhrs callbacks
xhrCallbacks[ handle ] = callback;
} }
// Add to list of active xhrs callbacks xhr.onreadystatechange = callback;
handle = xhrId++;
xhr.onreadystatechange = xhrCallbacks[ handle ] = callback;
} }
}, },
......
...@@ -158,7 +158,7 @@ jQuery.fn.extend({ ...@@ -158,7 +158,7 @@ jQuery.fn.extend({
if ( elem ) { if ( elem ) {
hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
if ( hooks && "get" in hooks && (ret = hooks.get( elem )) !== undefined ) { if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
return ret; return ret;
} }
...@@ -197,7 +197,7 @@ jQuery.fn.extend({ ...@@ -197,7 +197,7 @@ jQuery.fn.extend({
hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
// If set returns undefined, fall back to normal setting // If set returns undefined, fall back to normal setting
if ( !hooks || ("set" in hooks && hooks.set( this, val ) === undefined) ) { if ( !hooks || ("set" in hooks && hooks.set( this, val, "value" ) === undefined) ) {
this.value = val; this.value = val;
} }
}); });
...@@ -360,6 +360,15 @@ jQuery.extend({ ...@@ -360,6 +360,15 @@ jQuery.extend({
// We can't allow the type property to be changed (since it causes problems in IE) // We can't allow the type property to be changed (since it causes problems in IE)
if ( rtype.test( elem.nodeName ) && elem.parentNode ) { if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
jQuery.error( "type property can't be changed" ); jQuery.error( "type property can't be changed" );
} else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
// Setting the type on a radio button after the value resets the value in IE6-9
// Reset value to it's default in case type is set after value
var val = elem.getAttribute("value");
elem.setAttribute( "type", value );
if ( val ) {
elem.value = val;
}
return value;
} }
} }
}, },
...@@ -432,9 +441,11 @@ if ( !jQuery.support.getSetAttribute ) { ...@@ -432,9 +441,11 @@ if ( !jQuery.support.getSetAttribute ) {
}); });
// Use this for any attribute on a form in IE6/7 // Use this for any attribute on a form in IE6/7
// And the name attribute formHook = jQuery.attrHooks.name = jQuery.attrHooks.value = jQuery.valHooks.button = {
formHook = jQuery.attrHooks.name = {
get: function( elem, name ) { get: function( elem, name ) {
if ( name === "value" && !jQuery.nodeName( elem, "button" ) ) {
return elem.getAttribute( name );
}
var ret = elem.getAttributeNode( name ); var ret = elem.getAttributeNode( name );
// Return undefined if not specified instead of empty string // Return undefined if not specified instead of empty string
return ret && ret.specified ? return ret && ret.specified ?
...@@ -470,7 +481,10 @@ if ( !jQuery.support.getSetAttribute ) { ...@@ -470,7 +481,10 @@ if ( !jQuery.support.getSetAttribute ) {
jQuery.each([ "selected", "checked", "readOnly", "disabled" ], function( i, name ) { jQuery.each([ "selected", "checked", "readOnly", "disabled" ], function( i, name ) {
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
set: function( elem, value ) { set: function( elem, value ) {
if ( value === false ) { if ( value === true ) {
elem.setAttribute( name, name );
return value;
} else if ( value === false ) {
jQuery.removeAttr( elem, name ); jQuery.removeAttr( elem, name );
return value; return value;
} }
......
...@@ -731,7 +731,7 @@ jQuery.extend({ ...@@ -731,7 +731,7 @@ jQuery.extend({
} }
} }
// Go thorugh every key on the object, // Go through every key on the object,
} else { } else {
for ( key in elems ) { for ( key in elems ) {
value = callback( elems[ key ], key, arg ); value = callback( elems[ key ], key, arg );
...@@ -752,45 +752,23 @@ jQuery.extend({ ...@@ -752,45 +752,23 @@ jQuery.extend({
// Bind a function to a context, optionally partially applying any // Bind a function to a context, optionally partially applying any
// arguments. // arguments.
proxy: function( fn, context ) { proxy: function( fn, context ) {
var args, proxy;
// XXX BACKCOMPAT: Support old string method.
if ( typeof context === "string" ) { if ( typeof context === "string" ) {
fn = fn[ context ]; var tmp = fn[ context ];
context = arguments[0]; context = fn;
fn = tmp;
} }
// Quick check to determine if target is callable, in the spec // Quick check to determine if target is callable, in the spec
// this throws a TypeError, but we will just return undefined. // this throws a TypeError, but we will just return undefined.
if ( ! jQuery.isFunction( fn ) ) { if ( !jQuery.isFunction( fn ) ) {
return undefined; return undefined;
} }
if ( jQuery.support.nativeBind ) { // Simulated bind
// Native bind var args = slice.call( arguments, 2 ),
args = slice.call( arguments, 1 ); proxy = function() {
if ( args.length ) { return fn.apply( context, args.concat( slice.call( arguments ) ) );
proxy = Function.prototype.bind.apply( fn, args ); };
} else {
proxy = fn.bind( context );
}
} else {
// Simulated bind
args = slice.call( arguments, 2 );
if ( args.length ) {
proxy = function() {
return arguments.length ?
fn.apply( context, args.concat( slice.call( arguments ) ) ) :
fn.apply( context, args );
};
} else {
proxy = function() {
return arguments.length ?
fn.apply( context, arguments ) :
fn.call( context );
};
}
}
// Set the guid of unique handler to the same of original handler, so it can be removed // Set the guid of unique handler to the same of original handler, so it can be removed
proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
......
...@@ -28,19 +28,22 @@ jQuery.fn.extend({ ...@@ -28,19 +28,22 @@ jQuery.fn.extend({
} else { } else {
for ( var i = 0, j = this.length; i < j; i++ ) { for ( var i = 0, j = this.length; i < j; i++ ) {
elem = this[i]; elem = this[i];
display = elem.style.display;
// Reset the inline display of this element to learn if it is if ( elem.style ) {
// being hidden by cascaded rules or not display = elem.style.display;
if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
display = elem.style.display = ""; // Reset the inline display of this element to learn if it is
} // being hidden by cascaded rules or not
if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
display = elem.style.display = "";
}
// Set elements which have been overridden with display: none // Set elements which have been overridden with display: none
// in a stylesheet to whatever the default browser style is // in a stylesheet to whatever the default browser style is
// for such an element // for such an element
if ( display === "" && jQuery.css( elem, "display" ) === "none" ) { if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName)); jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
}
} }
} }
...@@ -48,10 +51,13 @@ jQuery.fn.extend({ ...@@ -48,10 +51,13 @@ jQuery.fn.extend({
// to avoid the constant reflow // to avoid the constant reflow
for ( i = 0; i < j; i++ ) { for ( i = 0; i < j; i++ ) {
elem = this[i]; elem = this[i];
display = elem.style.display;
if ( display === "" || display === "none" ) { if ( elem.style ) {
elem.style.display = jQuery._data(elem, "olddisplay") || ""; display = elem.style.display;
if ( display === "" || display === "none" ) {
elem.style.display = jQuery._data(elem, "olddisplay") || "";
}
} }
} }
...@@ -65,17 +71,21 @@ jQuery.fn.extend({ ...@@ -65,17 +71,21 @@ jQuery.fn.extend({
} else { } else {
for ( var i = 0, j = this.length; i < j; i++ ) { for ( var i = 0, j = this.length; i < j; i++ ) {
var display = jQuery.css( this[i], "display" ); if ( this[i].style ) {
var display = jQuery.css( this[i], "display" );
if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) { if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
jQuery._data( this[i], "olddisplay", display ); jQuery._data( this[i], "olddisplay", display );
}
} }
} }
// Set the display of the elements in a second loop // Set the display of the elements in a second loop
// to avoid the constant reflow // to avoid the constant reflow
for ( i = 0; i < j; i++ ) { for ( i = 0; i < j; i++ ) {
this[i].style.display = "none"; if ( this[i].style ) {
this[i].style.display = "none";
}
} }
return this; return this;
...@@ -165,7 +175,7 @@ jQuery.fn.extend({ ...@@ -165,7 +175,7 @@ jQuery.fn.extend({
this.style.display = "inline-block"; this.style.display = "inline-block";
} else { } else {
var display = defaultDisplay(this.nodeName); display = defaultDisplay(this.nodeName);
// inline-level elements accept inline-block; // inline-level elements accept inline-block;
// block-level elements need to be inline with layout // block-level elements need to be inline with layout
...@@ -266,6 +276,27 @@ jQuery.fn.extend({ ...@@ -266,6 +276,27 @@ jQuery.fn.extend({
}); });
// Animations created synchronously will run synchronously
function createFxNow() {
setTimeout( clearFxNow, 0 );
return ( fxNow = jQuery.now() );
}
function clearFxNow() {
fxNow = undefined;
}
// Generate parameters to create a standard animation
function genFx( type, num ) {
var obj = {};
jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
obj[ this ] = type;
});
return obj;
}
// Generate shortcuts for custom animations // Generate shortcuts for custom animations
jQuery.each({ jQuery.each({
slideDown: genFx("show", 1), slideDown: genFx("show", 1),
...@@ -581,25 +612,4 @@ function defaultDisplay( nodeName ) { ...@@ -581,25 +612,4 @@ function defaultDisplay( nodeName ) {
return elemdisplay[ nodeName ]; return elemdisplay[ nodeName ];
} }
// Animations created synchronously will run synchronously
function createFxNow() {
setTimeout( clearFxNow, 0 );
return ( fxNow = jQuery.now() );
}
function clearFxNow() {
fxNow = undefined;
}
// Generate parameters to create a standard animation
function genFx( type, num ) {
var obj = {};
jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
obj[ this ] = type;
});
return obj;
}
})( jQuery ); })( jQuery );
...@@ -63,7 +63,7 @@ jQuery.event = { ...@@ -63,7 +63,7 @@ jQuery.event = {
elemData.handle = eventHandle = function( e ) { elemData.handle = eventHandle = function( e ) {
// Discard the second event of a jQuery.event.trigger() and // Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded // when an event is called after a page has unloaded
return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
jQuery.event.handle.apply( eventHandle.elem, arguments ) : jQuery.event.handle.apply( eventHandle.elem, arguments ) :
undefined; undefined;
}; };
...@@ -910,7 +910,7 @@ jQuery.each(["bind", "one"], function( i, name ) { ...@@ -910,7 +910,7 @@ jQuery.each(["bind", "one"], function( i, name ) {
return this; return this;
} }
if ( jQuery.isFunction( data ) || data === false ) { if ( arguments.length === 2 || data === false ) {
fn = data; fn = data;
data = undefined; data = undefined;
} }
...@@ -1063,7 +1063,7 @@ jQuery.each(["live", "die"], function( i, name ) { ...@@ -1063,7 +1063,7 @@ jQuery.each(["live", "die"], function( i, name ) {
preType = type; preType = type;
if ( type === "focus" || type === "blur" ) { if ( liveMap[ type ] ) {
types.push( liveMap[ type ] + namespaces ); types.push( liveMap[ type ] + namespaces );
type = type + namespaces; type = type + namespaces;
...@@ -1134,6 +1134,11 @@ function liveHandler( event ) { ...@@ -1134,6 +1134,11 @@ function liveHandler( event ) {
if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
event.type = handleObj.preType; event.type = handleObj.preType;
related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
// Make sure not to accidentally match a child element with the same selector
if ( related && jQuery.contains( elem, related ) ) {
related = elem;
}
} }
if ( !related || related !== elem ) { if ( !related || related !== elem ) {
......
...@@ -70,7 +70,7 @@ jQuery.fn.extend({ ...@@ -70,7 +70,7 @@ jQuery.fn.extend({
} }
return elem; return elem;
}).append(this); }).append( this );
} }
return this; return this;
...@@ -379,13 +379,13 @@ function cloneCopyEvent( src, dest ) { ...@@ -379,13 +379,13 @@ function cloneCopyEvent( src, dest ) {
} }
function cloneFixAttributes( src, dest ) { function cloneFixAttributes( src, dest ) {
var nodeName;
// We do not need to do anything for non-Elements // We do not need to do anything for non-Elements
if ( dest.nodeType !== 1 ) { if ( dest.nodeType !== 1 ) {
return; return;
} }
var nodeName = dest.nodeName.toLowerCase();
// clearAttributes removes the attributes, which we don't want, // clearAttributes removes the attributes, which we don't want,
// but also removes the attachEvent events, which we *do* want // but also removes the attachEvent events, which we *do* want
if ( dest.clearAttributes ) { if ( dest.clearAttributes ) {
...@@ -398,6 +398,8 @@ function cloneFixAttributes( src, dest ) { ...@@ -398,6 +398,8 @@ function cloneFixAttributes( src, dest ) {
dest.mergeAttributes( src ); dest.mergeAttributes( src );
} }
nodeName = dest.nodeName.toLowerCase();
// IE6-8 fail to clone children inside object elements that use // IE6-8 fail to clone children inside object elements that use
// the proprietary classid attribute value (rather than the type // the proprietary classid attribute value (rather than the type
// attribute) to identify the type of content to display // attribute) to identify the type of content to display
...@@ -446,11 +448,10 @@ jQuery.buildFragment = function( args, nodes, scripts ) { ...@@ -446,11 +448,10 @@ jQuery.buildFragment = function( args, nodes, scripts ) {
args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) { args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
cacheable = true; cacheable = true;
cacheresults = jQuery.fragments[ args[0] ]; cacheresults = jQuery.fragments[ args[0] ];
if ( cacheresults ) { if ( cacheresults && cacheresults !== 1 ) {
if ( cacheresults !== 1 ) { fragment = cacheresults;
fragment = cacheresults;
}
} }
} }
...@@ -508,6 +509,21 @@ function getAll( elem ) { ...@@ -508,6 +509,21 @@ function getAll( elem ) {
} }
} }
// Used in clean, fixes the defaultChecked property
function fixDefaultChecked( elem ) {
if ( elem.type === "checkbox" || elem.type === "radio" ) {
elem.defaultChecked = elem.checked;
}
}
// Finds all inputs and passes them to fixDefaultChecked
function findInputs( elem ) {
if ( jQuery.nodeName( elem, "input" ) ) {
fixDefaultChecked( elem );
} else if ( elem.getElementsByTagName ) {
jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
}
}
jQuery.extend({ jQuery.extend({
clone: function( elem, dataAndEvents, deepDataAndEvents ) { clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var clone = elem.cloneNode(true), var clone = elem.cloneNode(true),
...@@ -578,54 +594,67 @@ jQuery.extend({ ...@@ -578,54 +594,67 @@ jQuery.extend({
} }
// Convert html string into DOM nodes // Convert html string into DOM nodes
if ( typeof elem === "string" && !rhtml.test( elem ) ) { if ( typeof elem === "string" ) {
elem = context.createTextNode( elem ); if ( !rhtml.test( elem ) ) {
elem = context.createTextNode( elem );
} else if ( typeof elem === "string" ) { } else {
// Fix "XHTML"-style tags in all browsers // Fix "XHTML"-style tags in all browsers
elem = elem.replace(rxhtmlTag, "<$1></$2>"); elem = elem.replace(rxhtmlTag, "<$1></$2>");
// Trim whitespace, otherwise indexOf won't work as expected // Trim whitespace, otherwise indexOf won't work as expected
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
wrap = wrapMap[ tag ] || wrapMap._default, wrap = wrapMap[ tag ] || wrapMap._default,
depth = wrap[0], depth = wrap[0],
div = context.createElement("div"); div = context.createElement("div");
// Go to html and back, then peel off extra wrappers // Go to html and back, then peel off extra wrappers
div.innerHTML = wrap[1] + elem + wrap[2]; div.innerHTML = wrap[1] + elem + wrap[2];
// Move to the right depth // Move to the right depth
while ( depth-- ) { while ( depth-- ) {
div = div.lastChild; div = div.lastChild;
} }
// Remove IE's autoinserted <tbody> from table fragments // Remove IE's autoinserted <tbody> from table fragments
if ( !jQuery.support.tbody ) { if ( !jQuery.support.tbody ) {
// String was a <table>, *may* have spurious <tbody> // String was a <table>, *may* have spurious <tbody>
var hasBody = rtbody.test(elem), var hasBody = rtbody.test(elem),
tbody = tag === "table" && !hasBody ? tbody = tag === "table" && !hasBody ?
div.firstChild && div.firstChild.childNodes : div.firstChild && div.firstChild.childNodes :
// String was a bare <thead> or <tfoot> // String was a bare <thead> or <tfoot>
wrap[1] === "<table>" && !hasBody ? wrap[1] === "<table>" && !hasBody ?
div.childNodes : div.childNodes :
[]; [];
for ( var j = tbody.length - 1; j >= 0 ; --j ) { for ( var j = tbody.length - 1; j >= 0 ; --j ) {
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
tbody[ j ].parentNode.removeChild( tbody[ j ] ); tbody[ j ].parentNode.removeChild( tbody[ j ] );
}
} }
} }
} // IE completely kills leading whitespace when innerHTML is used
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
}
// IE completely kills leading whitespace when innerHTML is used elem = div.childNodes;
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
} }
}
elem = div.childNodes; // Resets defaultChecked for any radios and checkboxes
// about to be appended to the DOM in IE 6/7 (#8060)
var len;
if ( !jQuery.support.appendChecked ) {
if ( elem[0] && typeof (len = elem.length) === "number" ) {
for ( i = 0; i < len; i++ ) {
findInputs( elem[i] );
}
} else {
findInputs( elem );
}
} }
if ( elem.nodeType ) { if ( elem.nodeType ) {
......
Subproject commit 69ecd019852c1421cbd81fe6ceb4e22a81022ea7 Subproject commit 4bcc09702d6dadfd0b90c7de3c8b206e97ff97f4
...@@ -77,10 +77,6 @@ jQuery.support = (function() { ...@@ -77,10 +77,6 @@ jQuery.support = (function() {
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
getSetAttribute: div.className !== "t", getSetAttribute: div.className !== "t",
// Test for presence of native Function#bind.
// Not in: >= Chrome 6, >= FireFox 3, Safari 5?, IE 9?, Opera 11?
nativeBind: jQuery.isFunction( Function.prototype.bind ),
// Will be defined later // Will be defined later
submitBubbles: true, submitBubbles: true,
changeBubbles: true, changeBubbles: true,
...@@ -119,6 +115,11 @@ jQuery.support = (function() { ...@@ -119,6 +115,11 @@ jQuery.support = (function() {
div.cloneNode( true ).fireEvent( "onclick" ); div.cloneNode( true ).fireEvent( "onclick" );
} }
input = document.createElement("input");
input.value = "t";
input.setAttribute("type", "radio");
support.radioValue = input.value === "t";
div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>"; div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
fragment = document.createDocumentFragment(); fragment = document.createDocumentFragment();
...@@ -185,6 +186,14 @@ jQuery.support = (function() { ...@@ -185,6 +186,14 @@ jQuery.support = (function() {
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
div.innerHTML = ""; div.innerHTML = "";
// Check if a disconnected checkbox will retain its checked
// value of true after appended to the DOM
input = document.createElement("input");
input.setAttribute("type", "checkbox");
input.checked = true;
div.appendChild( input );
support.appendChecked = input.checked;
// Check if div with explicit width and no margin-right incorrectly // Check if div with explicit width and no margin-right incorrectly
// gets computed margin-right based on width of container. For more // gets computed margin-right based on width of container. For more
// info see bug #3333 // info see bug #3333
......
...@@ -160,7 +160,7 @@ jQuery.fn.extend({ ...@@ -160,7 +160,7 @@ jQuery.fn.extend({
add: function( selector, context ) { add: function( selector, context ) {
var set = typeof selector === "string" ? var set = typeof selector === "string" ?
jQuery( selector, context ) : jQuery( selector, context ) :
jQuery.makeArray( selector ), jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
all = jQuery.merge( this.get(), set ); all = jQuery.merge( this.get(), set );
return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
......
...@@ -58,10 +58,10 @@ ...@@ -58,10 +58,10 @@
<div id="nothiddendiv" style="height:1px;background:white;" class="nothiddendiv"> <div id="nothiddendiv" style="height:1px;background:white;" class="nothiddendiv">
<div id="nothiddendivchild"></div> <div id="nothiddendivchild"></div>
</div> </div>
<!-- this iframe is outside the #main so it won't reload constantly wasting time, but it means the tests must be "safe" and clean up after themselves --> <!-- this iframe is outside the #qunit-fixture so it won't reload constantly wasting time, but it means the tests must be "safe" and clean up after themselves -->
<iframe id="loadediframe" name="loadediframe" style="display:none;" src="data/iframe.html"></iframe> <iframe id="loadediframe" name="loadediframe" style="display:none;" src="data/iframe.html"></iframe>
<dl id="dl" style="position:absolute;top:-32767px;left:-32767px;"> <dl id="dl" style="position:absolute;top:-32767px;left:-32767px;width:1px">
<div id="main"> <div id="qunit-fixture">
<p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> for more information.</p> <p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> for more information.</p>
<p id="ap"> <p id="ap">
Here are some links in a normal paragraph: <a id="google" href="http://www.google.com/" title="Google!">Google</a>, Here are some links in a normal paragraph: <a id="google" href="http://www.google.com/" title="Google!">Google</a>,
......
Subproject commit d404faf8f587fcbe6b8907943022e6318dd51e0c Subproject commit 9887663380693009874e8c76f0bf77a921931766
...@@ -1782,7 +1782,7 @@ test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() { ...@@ -1782,7 +1782,7 @@ test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
passed++; passed++;
if ( passed == 2 ) { if ( passed == 2 ) {
ok( true, "Check local and global callbacks after timeout" ); ok( true, "Check local and global callbacks after timeout" );
jQuery("#main").unbind("ajaxError"); jQuery("#qunit-fixture").unbind("ajaxError");
start(); start();
} }
}; };
...@@ -1792,7 +1792,7 @@ test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() { ...@@ -1792,7 +1792,7 @@ test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
start(); start();
}; };
jQuery("#main").ajaxError(pass); jQuery("#qunit-fixture").ajaxError(pass);
jQuery.ajax({ jQuery.ajax({
type: "GET", type: "GET",
......
...@@ -77,7 +77,7 @@ test("prop(String, Object)", function() { ...@@ -77,7 +77,7 @@ test("prop(String, Object)", function() {
}); });
test("attr(String)", function() { test("attr(String)", function() {
expect(32); expect(35);
equals( jQuery("#text1").attr("type"), "text", "Check for type attribute" ); equals( jQuery("#text1").attr("type"), "text", "Check for type attribute" );
equals( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" ); equals( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" );
...@@ -90,6 +90,7 @@ test("attr(String)", function() { ...@@ -90,6 +90,7 @@ test("attr(String)", function() {
equals( jQuery("#name").attr("name"), "name", "Check for name attribute" ); equals( jQuery("#name").attr("name"), "name", "Check for name attribute" );
equals( jQuery("#text1").attr("name"), "action", "Check for name attribute" ); equals( jQuery("#text1").attr("name"), "action", "Check for name attribute" );
ok( jQuery("#form").attr("action").indexOf("formaction") >= 0, "Check for action attribute" ); ok( jQuery("#form").attr("action").indexOf("formaction") >= 0, "Check for action attribute" );
equals( jQuery("#text1").attr("value", "t").attr("value"), "t", "Check setting the value attribute" );
equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" ); equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" );
equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" ); equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" );
...@@ -108,7 +109,7 @@ test("attr(String)", function() { ...@@ -108,7 +109,7 @@ test("attr(String)", function() {
equals( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" ); equals( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" );
// using innerHTML in IE causes href attribute to be serialized to the full path // using innerHTML in IE causes href attribute to be serialized to the full path
jQuery("<a/>").attr({ "id": "tAnchor5", "href": "#5" }).appendTo("#main"); jQuery("<a/>").attr({ "id": "tAnchor5", "href": "#5" }).appendTo("#qunit-fixture");
equals( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" ); equals( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" );
// list attribute is readonly by default in browsers that support it // list attribute is readonly by default in browsers that support it
...@@ -136,6 +137,11 @@ test("attr(String)", function() { ...@@ -136,6 +137,11 @@ test("attr(String)", function() {
ok( !!~jQuery("#dl").attr("style").indexOf("position"), "Check style attribute getter, also normalize css props to lowercase" ); ok( !!~jQuery("#dl").attr("style").indexOf("position"), "Check style attribute getter, also normalize css props to lowercase" );
ok( !!~jQuery("#foo").attr("style", "position:absolute;").attr("style").indexOf("position"), "Check style setter" ); ok( !!~jQuery("#foo").attr("style", "position:absolute;").attr("style").indexOf("position"), "Check style setter" );
// Check value on button element (#1954)
var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button");
equals( $button.attr("value"), "foobar", "Value retrieval on a button does not return innerHTML" );
equals( $button.attr("value", "baz").html(), "text", "Setting the value does not change innerHTML" );
ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." ); ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." );
ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." ); ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." );
}); });
...@@ -171,7 +177,7 @@ test("attr(Hash)", function() { ...@@ -171,7 +177,7 @@ test("attr(Hash)", function() {
}); });
test("attr(String, Object)", function() { test("attr(String, Object)", function() {
expect(29); expect(30);
var div = jQuery("div").attr("foo", "bar"), var div = jQuery("div").attr("foo", "bar"),
fail = false; fail = false;
...@@ -284,7 +290,10 @@ test("attr(String, Object)", function() { ...@@ -284,7 +290,10 @@ test("attr(String, Object)", function() {
} }
ok( thrown, "Exception thrown when trying to change type property" ); ok( thrown, "Exception thrown when trying to change type property" );
equals( "button", button.attr("type"), "Verify that you can't change the type of a button element" ); equals( "button", button.attr("type"), "Verify that you can't change the type of a button element" );
var $radio = jQuery("<input>", { "value": "sup", "type": "radio" }).appendTo("#testForm");
equals( $radio.val(), "sup", "Value is not reset when type is set after value on a radio" );
// Setting attributes on svg elements (bug #3116) // Setting attributes on svg elements (bug #3116)
var $svg = jQuery("<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' baseProfile='full' width='200' height='200'>" var $svg = jQuery("<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' baseProfile='full' width='200' height='200'>"
+ "<circle cx='200' cy='200' r='150' />" + "<circle cx='200' cy='200' r='150' />"
...@@ -426,7 +435,7 @@ test("removeProp(String)", function() { ...@@ -426,7 +435,7 @@ test("removeProp(String)", function() {
}); });
test("val()", function() { test("val()", function() {
expect(23); expect(25);
document.getElementById("text1").value = "bla"; document.getElementById("text1").value = "bla";
equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" ); equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
...@@ -488,6 +497,10 @@ test("val()", function() { ...@@ -488,6 +497,10 @@ test("val()", function() {
same( checks.serialize(), "test=1&test=on", "Get multiple checked values." ); same( checks.serialize(), "test=1&test=on", "Get multiple checked values." );
checks.remove(); checks.remove();
var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button");
equals( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" );
equals( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" );
}); });
var testVal = function(valueObj) { var testVal = function(valueObj) {
...@@ -547,6 +560,7 @@ test( "val(Array of Numbers) (Bug #7123)", function() { ...@@ -547,6 +560,7 @@ test( "val(Array of Numbers) (Bug #7123)", function() {
test("val(Function) with incoming value", function() { test("val(Function) with incoming value", function() {
expect(10); expect(10);
QUnit.reset();
var oldVal = jQuery("#text1").val(); var oldVal = jQuery("#text1").val();
jQuery("#text1").val(function(i, val) { jQuery("#text1").val(function(i, val) {
...@@ -599,7 +613,7 @@ test("val(Function) with incoming value", function() { ...@@ -599,7 +613,7 @@ test("val(Function) with incoming value", function() {
test("val(select) after form.reset() (Bug #2551)", function() { test("val(select) after form.reset() (Bug #2551)", function() {
expect(3); expect(3);
jQuery("<form id='kk' name='kk'><select id='kkk'><option value='cf'>cf</option><option value='gf'>gf</option></select></form>").appendTo("#main"); jQuery("<form id='kk' name='kk'><select id='kkk'><option value='cf'>cf</option><option value='gf'>gf</option></select></form>").appendTo("#qunit-fixture");
jQuery("#kkk").val( "gf" ); jQuery("#kkk").val( "gf" );
......
...@@ -29,7 +29,7 @@ test("jQuery()", function() { ...@@ -29,7 +29,7 @@ test("jQuery()", function() {
equals( jQuery(window).length, 1, "Correct number of elements generated for jQuery(window)" ); equals( jQuery(window).length, 1, "Correct number of elements generated for jQuery(window)" );
var main = jQuery("#main"); var main = jQuery("#qunit-fixture");
same( jQuery("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" ); same( jQuery("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
/* /*
...@@ -115,54 +115,54 @@ test("selector state", function() { ...@@ -115,54 +115,54 @@ test("selector state", function() {
equals( test.selector, "", "Body Selector" ); equals( test.selector, "", "Body Selector" );
equals( test.context, document.body, "Body Context" ); equals( test.context, document.body, "Body Context" );
test = jQuery("#main"); test = jQuery("#qunit-fixture");
equals( test.selector, "#main", "#main Selector" ); equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
equals( test.context, document, "#main Context" ); equals( test.context, document, "#qunit-fixture Context" );
test = jQuery("#notfoundnono"); test = jQuery("#notfoundnono");
equals( test.selector, "#notfoundnono", "#notfoundnono Selector" ); equals( test.selector, "#notfoundnono", "#notfoundnono Selector" );
equals( test.context, document, "#notfoundnono Context" ); equals( test.context, document, "#notfoundnono Context" );
test = jQuery("#main", document); test = jQuery("#qunit-fixture", document);
equals( test.selector, "#main", "#main Selector" ); equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
equals( test.context, document, "#main Context" ); equals( test.context, document, "#qunit-fixture Context" );
test = jQuery("#main", document.body); test = jQuery("#qunit-fixture", document.body);
equals( test.selector, "#main", "#main Selector" ); equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
equals( test.context, document.body, "#main Context" ); equals( test.context, document.body, "#qunit-fixture Context" );
// Test cloning // Test cloning
test = jQuery(test); test = jQuery(test);
equals( test.selector, "#main", "#main Selector" ); equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" );
equals( test.context, document.body, "#main Context" ); equals( test.context, document.body, "#qunit-fixture Context" );
test = jQuery(document.body).find("#main"); test = jQuery(document.body).find("#qunit-fixture");
equals( test.selector, "#main", "#main find Selector" ); equals( test.selector, "#qunit-fixture", "#qunit-fixture find Selector" );
equals( test.context, document.body, "#main find Context" ); equals( test.context, document.body, "#qunit-fixture find Context" );
test = jQuery("#main").filter("div"); test = jQuery("#qunit-fixture").filter("div");
equals( test.selector, "#main.filter(div)", "#main filter Selector" ); equals( test.selector, "#qunit-fixture.filter(div)", "#qunit-fixture filter Selector" );
equals( test.context, document, "#main filter Context" ); equals( test.context, document, "#qunit-fixture filter Context" );
test = jQuery("#main").not("div"); test = jQuery("#qunit-fixture").not("div");
equals( test.selector, "#main.not(div)", "#main not Selector" ); equals( test.selector, "#qunit-fixture.not(div)", "#qunit-fixture not Selector" );
equals( test.context, document, "#main not Context" ); equals( test.context, document, "#qunit-fixture not Context" );
test = jQuery("#main").filter("div").not("div"); test = jQuery("#qunit-fixture").filter("div").not("div");
equals( test.selector, "#main.filter(div).not(div)", "#main filter, not Selector" ); equals( test.selector, "#qunit-fixture.filter(div).not(div)", "#qunit-fixture filter, not Selector" );
equals( test.context, document, "#main filter, not Context" ); equals( test.context, document, "#qunit-fixture filter, not Context" );
test = jQuery("#main").filter("div").not("div").end(); test = jQuery("#qunit-fixture").filter("div").not("div").end();
equals( test.selector, "#main.filter(div)", "#main filter, not, end Selector" ); equals( test.selector, "#qunit-fixture.filter(div)", "#qunit-fixture filter, not, end Selector" );
equals( test.context, document, "#main filter, not, end Context" ); equals( test.context, document, "#qunit-fixture filter, not, end Context" );
test = jQuery("#main").parent("body"); test = jQuery("#qunit-fixture").parent("body");
equals( test.selector, "#main.parent(body)", "#main parent Selector" ); equals( test.selector, "#qunit-fixture.parent(body)", "#qunit-fixture parent Selector" );
equals( test.context, document, "#main parent Context" ); equals( test.context, document, "#qunit-fixture parent Context" );
test = jQuery("#main").eq(0); test = jQuery("#qunit-fixture").eq(0);
equals( test.selector, "#main.slice(0,1)", "#main eq Selector" ); equals( test.selector, "#qunit-fixture.slice(0,1)", "#qunit-fixture eq Selector" );
equals( test.context, document, "#main eq Context" ); equals( test.context, document, "#qunit-fixture eq Context" );
var d = "<div />"; var d = "<div />";
equals( equals(
...@@ -228,7 +228,7 @@ test("noConflict", function() { ...@@ -228,7 +228,7 @@ test("noConflict", function() {
equals( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" ); equals( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" );
equals( jQuery, originaljQuery, "Make sure jQuery was reverted." ); equals( jQuery, originaljQuery, "Make sure jQuery was reverted." );
equals( $, original$, "Make sure $ was reverted." ); equals( $, original$, "Make sure $ was reverted." );
ok( $$("#main").html("test"), "Make sure that jQuery still works." ); ok( $$("#qunit-fixture").html("test"), "Make sure that jQuery still works." );
jQuery = $$; jQuery = $$;
}); });
...@@ -571,29 +571,29 @@ test("end()", function() { ...@@ -571,29 +571,29 @@ test("end()", function() {
test("length", function() { test("length", function() {
expect(1); expect(1);
equals( jQuery("#main p").length, 6, "Get Number of Elements Found" ); equals( jQuery("#qunit-fixture p").length, 6, "Get Number of Elements Found" );
}); });
test("size()", function() { test("size()", function() {
expect(1); expect(1);
equals( jQuery("#main p").size(), 6, "Get Number of Elements Found" ); equals( jQuery("#qunit-fixture p").size(), 6, "Get Number of Elements Found" );
}); });
test("get()", function() { test("get()", function() {
expect(1); expect(1);
same( jQuery("#main p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" ); same( jQuery("#qunit-fixture p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
}); });
test("toArray()", function() { test("toArray()", function() {
expect(1); expect(1);
same( jQuery("#main p").toArray(), same( jQuery("#qunit-fixture p").toArray(),
q("firstp","ap","sndp","en","sap","first"), q("firstp","ap","sndp","en","sap","first"),
"Convert jQuery object to an Array" ) "Convert jQuery object to an Array" )
}) })
test("get(Number)", function() { test("get(Number)", function() {
expect(2); expect(2);
equals( jQuery("#main p").get(0), document.getElementById("firstp"), "Get A Single Element" ); equals( jQuery("#qunit-fixture p").get(0), document.getElementById("firstp"), "Get A Single Element" );
strictEqual( jQuery("#firstp").get(1), undefined, "Try get with index larger elements count" ); strictEqual( jQuery("#firstp").get(1), undefined, "Try get with index larger elements count" );
}); });
...@@ -910,7 +910,7 @@ test("jQuery.isEmptyObject", function(){ ...@@ -910,7 +910,7 @@ test("jQuery.isEmptyObject", function(){
}); });
test("jQuery.proxy", function(){ test("jQuery.proxy", function(){
expect(6); expect(7);
var test = function(){ equals( this, thisObject, "Make sure that scope is set properly." ); }; var test = function(){ equals( this, thisObject, "Make sure that scope is set properly." ); };
var thisObject = { foo: "bar", method: test }; var thisObject = { foo: "bar", method: test };
...@@ -921,6 +921,9 @@ test("jQuery.proxy", function(){ ...@@ -921,6 +921,9 @@ test("jQuery.proxy", function(){
// Basic scoping // Basic scoping
jQuery.proxy( test, thisObject )(); jQuery.proxy( test, thisObject )();
// Another take on it
jQuery.proxy( thisObject, "method" )();
// Make sure it doesn't freak out // Make sure it doesn't freak out
equals( jQuery.proxy( null, thisObject ), undefined, "Make sure no function was returned." ); equals( jQuery.proxy( null, thisObject ), undefined, "Make sure no function was returned." );
......
...@@ -3,7 +3,7 @@ module("css", { teardown: moduleTeardown }); ...@@ -3,7 +3,7 @@ module("css", { teardown: moduleTeardown });
test("css(String|Hash)", function() { test("css(String|Hash)", function() {
expect( 42 ); expect( 42 );
equals( jQuery("#main").css("display"), "block", "Check for css property \"display\""); equals( jQuery("#qunit-fixture").css("display"), "block", "Check for css property \"display\"");
ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible"); ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible");
jQuery("#nothiddendiv").css({display: "none"}); jQuery("#nothiddendiv").css({display: "none"});
......
...@@ -316,7 +316,7 @@ test("data-* attributes", function() { ...@@ -316,7 +316,7 @@ test("data-* attributes", function() {
div.remove(); div.remove();
child.appendTo("#main"); child.appendTo("#qunit-fixture");
equals( child.data("myobj"), "old data", "Value accessed from data-* attribute"); equals( child.data("myobj"), "old data", "Value accessed from data-* attribute");
child.data("myobj", "replaced"); child.data("myobj", "replaced");
...@@ -406,7 +406,7 @@ test("data-* attributes", function() { ...@@ -406,7 +406,7 @@ test("data-* attributes", function() {
} }
var metadata = "<ol><li class='test test2' data-foo='bar' data-bar='baz' data-arr='[1,2]'>Some stuff</li><li class='test test2' data-test='bar' data-bar='baz'>Some stuff</li><li class='test test2' data-zoooo='bar' data-bar='{\"test\":\"baz\"}'>Some stuff</li><li class='test test2' data-number=true data-stuff='[2,8]'>Some stuff</li></ol>", var metadata = "<ol><li class='test test2' data-foo='bar' data-bar='baz' data-arr='[1,2]'>Some stuff</li><li class='test test2' data-test='bar' data-bar='baz'>Some stuff</li><li class='test test2' data-zoooo='bar' data-bar='{\"test\":\"baz\"}'>Some stuff</li><li class='test test2' data-number=true data-stuff='[2,8]'>Some stuff</li></ol>",
elem = jQuery(metadata).appendTo("#main"); elem = jQuery(metadata).appendTo("#qunit-fixture");
elem.find("li").each(testData); elem.find("li").each(testData);
elem.remove(); elem.remove();
......
...@@ -2,7 +2,7 @@ module("effects", { teardown: moduleTeardown }); ...@@ -2,7 +2,7 @@ module("effects", { teardown: moduleTeardown });
test("sanity check", function() { test("sanity check", function() {
expect(1); expect(1);
ok( jQuery("#dl:visible, #main:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects" ); ok( jQuery("#dl:visible, #qunit-fixture:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects" );
}); });
test("show()", function() { test("show()", function() {
...@@ -14,7 +14,7 @@ test("show()", function() { ...@@ -14,7 +14,7 @@ test("show()", function() {
equals( hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible." ); equals( hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible." );
var div = jQuery("<div>").hide().appendTo("#main").show(); var div = jQuery("<div>").hide().appendTo("#qunit-fixture").show();
equal( div.css("display"), "block", "Make sure pre-hidden divs show" ); equal( div.css("display"), "block", "Make sure pre-hidden divs show" );
...@@ -32,7 +32,7 @@ test("show()", function() { ...@@ -32,7 +32,7 @@ test("show()", function() {
hiddendiv.css("display",""); hiddendiv.css("display","");
var pass = true, div = jQuery("#main div"); var pass = true, div = jQuery("#qunit-fixture div");
div.show().each(function(){ div.show().each(function(){
if ( this.style.display == "none" ) pass = false; if ( this.style.display == "none" ) pass = false;
}); });
...@@ -62,7 +62,7 @@ test("show()", function() { ...@@ -62,7 +62,7 @@ test("show()", function() {
}); });
// #show-tests * is set display: none in CSS // #show-tests * is set display: none in CSS
jQuery("#main").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>"); jQuery("#qunit-fixture").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
var old = jQuery("#test-table").show().css("display") !== "table"; var old = jQuery("#test-table").show().css("display") !== "table";
jQuery("#test-table").remove(); jQuery("#test-table").remove();
...@@ -88,6 +88,10 @@ test("show()", function() { ...@@ -88,6 +88,10 @@ test("show()", function() {
var elem = jQuery(selector, "#show-tests").show(); var elem = jQuery(selector, "#show-tests").show();
equals( elem.css("display"), expected, "Show using correct display type for " + selector ); equals( elem.css("display"), expected, "Show using correct display type for " + selector );
}); });
// Make sure that showing or hiding a text node doesn't cause an error
jQuery("<div>test</div> text <span>test</span>").show().remove();
jQuery("<div>test</div> text <span>test</span>").hide().remove();
}); });
test("show(Number) - other displays", function() { test("show(Number) - other displays", function() {
...@@ -96,7 +100,7 @@ test("show(Number) - other displays", function() { ...@@ -96,7 +100,7 @@ test("show(Number) - other displays", function() {
stop(); stop();
// #show-tests * is set display: none in CSS // #show-tests * is set display: none in CSS
jQuery("#main").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>"); jQuery("#qunit-fixture").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
var old = jQuery("#test-table").show().css("display") !== "table", var old = jQuery("#test-table").show().css("display") !== "table",
num = 0; num = 0;
...@@ -138,7 +142,7 @@ test("Persist correct display value", function() { ...@@ -138,7 +142,7 @@ test("Persist correct display value", function() {
stop(); stop();
// #show-tests * is set display: none in CSS // #show-tests * is set display: none in CSS
jQuery("#main").append("<div id='show-tests'><span style='position:absolute;'>foo</span></div>"); jQuery("#qunit-fixture").append("<div id='show-tests'><span style='position:absolute;'>foo</span></div>");
var $span = jQuery("#show-tests span"), var $span = jQuery("#show-tests span"),
displayNone = $span.css("display"), displayNone = $span.css("display"),
...@@ -581,7 +585,7 @@ jQuery.checkOverflowDisplay = function(){ ...@@ -581,7 +585,7 @@ jQuery.checkOverflowDisplay = function(){
} }
test( "jQuery.fx.prototype.cur()", 6, function() { test( "jQuery.fx.prototype.cur()", 6, function() {
var div = jQuery( "<div></div>" ).appendTo( "#main" ).css({ var div = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" ).css({
color: "#ABC", color: "#ABC",
border: "5px solid black", border: "5px solid black",
left: "auto", left: "auto",
...@@ -954,7 +958,7 @@ test("hide hidden elements (bug #7141)", function() { ...@@ -954,7 +958,7 @@ test("hide hidden elements (bug #7141)", function() {
expect(3); expect(3);
QUnit.reset(); QUnit.reset();
var div = jQuery("<div style='display:none'></div>").appendTo("#main"); var div = jQuery("<div style='display:none'></div>").appendTo("#qunit-fixture");
equals( div.css("display"), "none", "Element is hidden by default" ); equals( div.css("display"), "none", "Element is hidden by default" );
div.hide(); div.hide();
ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" ); ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
...@@ -969,7 +973,7 @@ test("hide hidden elements, with animation (bug #7141)", function() { ...@@ -969,7 +973,7 @@ test("hide hidden elements, with animation (bug #7141)", function() {
QUnit.reset(); QUnit.reset();
stop(); stop();
var div = jQuery("<div style='display:none'></div>").appendTo("#main"); var div = jQuery("<div style='display:none'></div>").appendTo("#qunit-fixture");
equals( div.css("display"), "none", "Element is hidden by default" ); equals( div.css("display"), "none", "Element is hidden by default" );
div.hide(1, function () { div.hide(1, function () {
ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" ); ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
...@@ -982,7 +986,7 @@ test("hide hidden elements, with animation (bug #7141)", function() { ...@@ -982,7 +986,7 @@ test("hide hidden elements, with animation (bug #7141)", function() {
test("animate unit-less properties (#4966)", 2, function() { test("animate unit-less properties (#4966)", 2, function() {
stop(); stop();
var div = jQuery( "<div style='z-index: 0; position: absolute;'></div>" ).appendTo( "#main" ); var div = jQuery( "<div style='z-index: 0; position: absolute;'></div>" ).appendTo( "#qunit-fixture" );
equal( div.css( "z-index" ), "0", "z-index is 0" ); equal( div.css( "z-index" ), "0", "z-index is 0" );
div.animate({ zIndex: 2 }, function() { div.animate({ zIndex: 2 }, function() {
equal( div.css( "z-index" ), "2", "z-index is 2" ); equal( div.css( "z-index" ), "2", "z-index is 2" );
......
...@@ -15,7 +15,7 @@ test("null or undefined handler", function() { ...@@ -15,7 +15,7 @@ test("null or undefined handler", function() {
}); });
test("bind(), with data", function() { test("bind(), with data", function() {
expect(3); expect(4);
var handler = function(event) { var handler = function(event) {
ok( event.data, "bind() with data, check passed data exists" ); ok( event.data, "bind() with data, check passed data exists" );
equals( event.data.foo, "bar", "bind() with data, Check value of passed data" ); equals( event.data.foo, "bar", "bind() with data, Check value of passed data" );
...@@ -23,6 +23,12 @@ test("bind(), with data", function() { ...@@ -23,6 +23,12 @@ test("bind(), with data", function() {
jQuery("#firstp").bind("click", {foo: "bar"}, handler).click().unbind("click", handler); jQuery("#firstp").bind("click", {foo: "bar"}, handler).click().unbind("click", handler);
ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." ); ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." );
var test = function(){};
var handler2 = function(event) {
equals( event.data, test, "bind() with function data, Check value of passed data" );
};
jQuery("#firstp").bind("click", test, handler2).click().unbind("click", handler2);
}); });
test("click(), with data", function() { test("click(), with data", function() {
...@@ -163,7 +169,7 @@ test("bind(), namespace with special add", function() { ...@@ -163,7 +169,7 @@ test("bind(), namespace with special add", function() {
}); });
// Should trigger 2 // Should trigger 2
div.appendTo("#main").remove(); div.appendTo("#qunit-fixture").remove();
delete jQuery.event.special.test; delete jQuery.event.special.test;
}); });
...@@ -301,7 +307,7 @@ test("live/delegate immediate propagation", function() { ...@@ -301,7 +307,7 @@ test("live/delegate immediate propagation", function() {
test("bind/delegate bubbling, isDefaultPrevented", function() { test("bind/delegate bubbling, isDefaultPrevented", function() {
expect(2); expect(2);
var $anchor2 = jQuery( "#anchor2" ), var $anchor2 = jQuery( "#anchor2" ),
$main = jQuery( "#main" ), $main = jQuery( "#qunit-fixture" ),
fakeClick = function($jq) { fakeClick = function($jq) {
// Use a native click so we don't get jQuery simulated bubbling // Use a native click so we don't get jQuery simulated bubbling
if ( document.createEvent ) { if ( document.createEvent ) {
...@@ -409,7 +415,7 @@ test("bind(), namespaced events, cloned events", 18, function() { ...@@ -409,7 +415,7 @@ test("bind(), namespaced events, cloned events", 18, function() {
}).trigger("tester"); }).trigger("tester");
// Make sure events stick with appendTo'd elements (which are cloned) #2027 // Make sure events stick with appendTo'd elements (which are cloned) #2027
jQuery("<a href='#fail' class='test'>test</a>").click(function(){ return false; }).appendTo("#main"); jQuery("<a href='#fail' class='test'>test</a>").click(function(){ return false; }).appendTo("#qunit-fixture");
ok( jQuery("a.test:first").triggerHandler("click") === false, "Handler is bound to appendTo'd elements" ); ok( jQuery("a.test:first").triggerHandler("click") === false, "Handler is bound to appendTo'd elements" );
}); });
...@@ -532,7 +538,7 @@ test("bind(name, false), unbind(name, false)", function() { ...@@ -532,7 +538,7 @@ test("bind(name, false), unbind(name, false)", function() {
expect(3); expect(3);
var main = 0; var main = 0;
jQuery("#main").bind("click", function(e){ main++; }); jQuery("#qunit-fixture").bind("click", function(e){ main++; });
jQuery("#ap").trigger("click"); jQuery("#ap").trigger("click");
equals( main, 1, "Verify that the trigger happened correctly." ); equals( main, 1, "Verify that the trigger happened correctly." );
...@@ -547,14 +553,14 @@ test("bind(name, false), unbind(name, false)", function() { ...@@ -547,14 +553,14 @@ test("bind(name, false), unbind(name, false)", function() {
equals( main, 1, "Verify that the trigger happened correctly." ); equals( main, 1, "Verify that the trigger happened correctly." );
// manually clean up events from elements outside the fixture // manually clean up events from elements outside the fixture
jQuery("#main").unbind("click"); jQuery("#qunit-fixture").unbind("click");
}); });
test("live(name, false), die(name, false)", function() { test("live(name, false), die(name, false)", function() {
expect(3); expect(3);
var main = 0; var main = 0;
jQuery("#main").live("click", function(e){ main++; }); jQuery("#qunit-fixture").live("click", function(e){ main++; });
jQuery("#ap").trigger("click"); jQuery("#ap").trigger("click");
equals( main, 1, "Verify that the trigger happened correctly." ); equals( main, 1, "Verify that the trigger happened correctly." );
...@@ -567,7 +573,7 @@ test("live(name, false), die(name, false)", function() { ...@@ -567,7 +573,7 @@ test("live(name, false), die(name, false)", function() {
jQuery("#ap").die("click", false); jQuery("#ap").die("click", false);
jQuery("#ap").trigger("click"); jQuery("#ap").trigger("click");
equals( main, 1, "Verify that the trigger happened correctly." ); equals( main, 1, "Verify that the trigger happened correctly." );
jQuery("#main").die("click"); jQuery("#qunit-fixture").die("click");
}); });
test("delegate(selector, name, false), undelegate(selector, name, false)", function() { test("delegate(selector, name, false), undelegate(selector, name, false)", function() {
...@@ -575,7 +581,7 @@ test("delegate(selector, name, false), undelegate(selector, name, false)", funct ...@@ -575,7 +581,7 @@ test("delegate(selector, name, false), undelegate(selector, name, false)", funct
var main = 0; var main = 0;
jQuery("#main").delegate("#ap", "click", function(e){ main++; }); jQuery("#qunit-fixture").delegate("#ap", "click", function(e){ main++; });
jQuery("#ap").trigger("click"); jQuery("#ap").trigger("click");
equals( main, 1, "Verify that the trigger happened correctly." ); equals( main, 1, "Verify that the trigger happened correctly." );
...@@ -588,7 +594,7 @@ test("delegate(selector, name, false), undelegate(selector, name, false)", funct ...@@ -588,7 +594,7 @@ test("delegate(selector, name, false), undelegate(selector, name, false)", funct
jQuery("#ap").undelegate("#groups", "click", false); jQuery("#ap").undelegate("#groups", "click", false);
jQuery("#groups").trigger("click"); jQuery("#groups").trigger("click");
equals( main, 1, "Verify that the trigger happened correctly." ); equals( main, 1, "Verify that the trigger happened correctly." );
jQuery("#main").undelegate("#ap", "click"); jQuery("#qunit-fixture").undelegate("#ap", "click");
}); });
test("bind()/trigger()/unbind() on plain object", function() { test("bind()/trigger()/unbind() on plain object", function() {
...@@ -792,7 +798,7 @@ test("trigger() bubbling", function() { ...@@ -792,7 +798,7 @@ test("trigger() bubbling", function() {
jQuery(document).bind("click", function(e){ if ( e.target !== document) { doc++; } }); jQuery(document).bind("click", function(e){ if ( e.target !== document) { doc++; } });
jQuery("html").bind("click", function(e){ html++; }); jQuery("html").bind("click", function(e){ html++; });
jQuery("body").bind("click", function(e){ body++; }); jQuery("body").bind("click", function(e){ body++; });
jQuery("#main").bind("click", function(e){ main++; }); jQuery("#qunit-fixture").bind("click", function(e){ main++; });
jQuery("#ap").bind("click", function(){ ap++; return false; }); jQuery("#ap").bind("click", function(){ ap++; return false; });
jQuery("html").trigger("click"); jQuery("html").trigger("click");
...@@ -806,7 +812,7 @@ test("trigger() bubbling", function() { ...@@ -806,7 +812,7 @@ test("trigger() bubbling", function() {
equals( html, 2, "Body bubble" ); equals( html, 2, "Body bubble" );
equals( body, 1, "Body bubble" ); equals( body, 1, "Body bubble" );
jQuery("#main").trigger("click"); jQuery("#qunit-fixture").trigger("click");
equals( win, 3, "Main bubble" ); equals( win, 3, "Main bubble" );
equals( doc, 3, "Main bubble" ); equals( doc, 3, "Main bubble" );
equals( html, 3, "Main bubble" ); equals( html, 3, "Main bubble" );
...@@ -822,11 +828,11 @@ test("trigger() bubbling", function() { ...@@ -822,11 +828,11 @@ test("trigger() bubbling", function() {
// manually clean up events from elements outside the fixture // manually clean up events from elements outside the fixture
jQuery(document).unbind("click"); jQuery(document).unbind("click");
jQuery("html, body, #main").unbind("click"); jQuery("html, body, #qunit-fixture").unbind("click");
}); });
test("trigger(type, [data], [fn])", function() { test("trigger(type, [data], [fn])", function() {
expect(14); expect(16);
var handler = function(event, a, b, c) { var handler = function(event, a, b, c) {
equals( event.type, "click", "check passed data" ); equals( event.type, "click", "check passed data" );
...@@ -843,7 +849,24 @@ test("trigger(type, [data], [fn])", function() { ...@@ -843,7 +849,24 @@ test("trigger(type, [data], [fn])", function() {
ok( true, "Native call was triggered" ); ok( true, "Native call was triggered" );
}; };
// Triggers handlrs and native
$elem.live('mouseenter', function(){
ok( true, 'Trigger mouseenter bound by live' );
});
$elem.live('mouseleave', function(){
ok( true, 'Trigger mouseleave bound by live' );
});
$elem.trigger('mouseenter');
$elem.trigger('mouseleave');
$elem.die('mouseenter');
$elem.die('mouseleave');
// Triggers handlrs and native
// Trigger 5 // Trigger 5
$elem.bind("click", handler).trigger("click", [1, "2", "abc"]); $elem.bind("click", handler).trigger("click", [1, "2", "abc"]);
...@@ -866,7 +889,7 @@ test("trigger(type, [data], [fn])", function() { ...@@ -866,7 +889,7 @@ test("trigger(type, [data], [fn])", function() {
pass = true; pass = true;
try { try {
jQuery("#main table:first").bind("test:test", function(){}).trigger("test:test"); jQuery("#qunit-fixture table:first").bind("test:test", function(){}).trigger("test:test");
} catch (e) { } catch (e) {
pass = false; pass = false;
} }
...@@ -1183,11 +1206,11 @@ test(".live()/.die()", function() { ...@@ -1183,11 +1206,11 @@ test(".live()/.die()", function() {
jQuery("div").die("submit"); jQuery("div").die("submit");
// Test binding with a different context // Test binding with a different context
var clicked = 0, container = jQuery("#main")[0]; var clicked = 0, container = jQuery("#qunit-fixture")[0];
jQuery("#foo", container).live("click", function(e){ clicked++; }); jQuery("#foo", container).live("click", function(e){ clicked++; });
jQuery("div").trigger("click"); jQuery("div").trigger("click");
jQuery("#foo").trigger("click"); jQuery("#foo").trigger("click");
jQuery("#main").trigger("click"); jQuery("#qunit-fixture").trigger("click");
jQuery("body").trigger("click"); jQuery("body").trigger("click");
equals( clicked, 2, "live with a context" ); equals( clicked, 2, "live with a context" );
...@@ -1710,11 +1733,11 @@ test(".delegate()/.undelegate()", function() { ...@@ -1710,11 +1733,11 @@ test(".delegate()/.undelegate()", function() {
jQuery("#body").undelegate("div", "submit"); jQuery("#body").undelegate("div", "submit");
// Test binding with a different context // Test binding with a different context
var clicked = 0, container = jQuery("#main")[0]; var clicked = 0, container = jQuery("#qunit-fixture")[0];
jQuery("#main").delegate("#foo", "click", function(e){ clicked++; }); jQuery("#qunit-fixture").delegate("#foo", "click", function(e){ clicked++; });
jQuery("div").trigger("click"); jQuery("div").trigger("click");
jQuery("#foo").trigger("click"); jQuery("#foo").trigger("click");
jQuery("#main").trigger("click"); jQuery("#qunit-fixture").trigger("click");
jQuery("body").trigger("click"); jQuery("body").trigger("click");
equals( clicked, 2, "delegate with a context" ); equals( clicked, 2, "delegate with a context" );
...@@ -1722,7 +1745,7 @@ test(".delegate()/.undelegate()", function() { ...@@ -1722,7 +1745,7 @@ test(".delegate()/.undelegate()", function() {
ok( jQuery._data(container, "events").live, "delegate with a context" ); ok( jQuery._data(container, "events").live, "delegate with a context" );
// Test unbinding with a different context // Test unbinding with a different context
jQuery("#main").undelegate("#foo", "click"); jQuery("#qunit-fixture").undelegate("#foo", "click");
jQuery("#foo").trigger("click"); jQuery("#foo").trigger("click");
equals( clicked, 2, "undelegate with a context"); equals( clicked, 2, "undelegate with a context");
......
This diff is collapsed.
This diff is collapsed.
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