merge with master and resolve more conflicts

This commit is contained in:
louisremi 2011-04-12 11:29:25 +02:00
commit a5604aedb7
19 changed files with 322 additions and 87 deletions

View file

@ -111,7 +111,7 @@ update_submodules:
# update the submodules to the latest at the most logical branch # update the submodules to the latest at the most logical branch
pull_submodules: pull_submodules:
@@git submodule foreach "git pull origin \$$(git branch --no-color --contains \$$(git rev-parse HEAD) | grep -v \( | head -1)" @@git submodule foreach "git pull \$$(git config remote.origin.url)"
@@git submodule summary @@git submodule summary
pull: pull_submodules pull: pull_submodules

View file

@ -63,7 +63,7 @@ As the source code is handled by the version control system Git, it's useful to
### Submodules ### ### Submodules ###
The repository uses submodules, which normally are handles directly by the Makefile, but sometimes you want to The repository uses submodules, which normally are handled directly by the Makefile, but sometimes you want to
be able to work with them manually. be able to work with them manually.
Following are the steps to manually get the submodules: Following are the steps to manually get the submodules:
@ -86,7 +86,7 @@ If you want to work inside a submodule, it is possible, but first you need to ch
1. `cd src/sizzle` 1. `cd src/sizzle`
2. `git checkout master` 2. `git checkout master`
After you've commited your changes to the submodule, you'll update the jquery project to point to the new commit, After you've committed your changes to the submodule, you'll update the jquery project to point to the new commit,
but remember to push the submodule changes before pushing the new jquery commit: but remember to push the submodule changes before pushing the new jquery commit:
1. `cd src/sizzle` 1. `cd src/sizzle`
@ -99,12 +99,12 @@ The makefile has some targets to simplify submodule handling:
#### `make update_submodules` #### #### `make update_submodules` ####
checks out the commit pointed to byu jquery, but merges your local changes, if any. This target is executed checks out the commit pointed to by jquery, but merges your local changes, if any. This target is executed
when you are doing a normal `make`. when you are doing a normal `make`.
#### `make pull_submodules` #### #### `make pull_submodules` ####
updates the content of the submoduels to what is probably the latest upstream code updates the content of the submodules to what is probably the latest upstream code.
#### `make pull` #### #### `make pull` ####

View file

@ -479,7 +479,7 @@ jQuery.each([ "selected", "checked", "readOnly", "disabled" ], function( i, name
// Some attributes require a special call on IE // Some attributes require a special call on IE
if ( !jQuery.support.hrefNormalized ) { if ( !jQuery.support.hrefNormalized ) {
jQuery.each([ "href", "src", "width", "height", "list" ], function( i, name ) { jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
get: function( elem ) { get: function( elem ) {
var ret = elem.getAttribute( name, 2 ); var ret = elem.getAttribute( name, 2 );

View file

@ -613,8 +613,11 @@ jQuery.extend({
} }
} }
} else { } else {
for ( var value = object[0]; for ( ; i < length; ) {
i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {} if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
break;
}
}
} }
} }

View file

@ -122,11 +122,17 @@ jQuery.extend({
}, },
css: function( elem, name, extra ) { css: function( elem, name, extra ) {
// Make sure that we're working with the right name var ret, hooks;
var ret, origName = jQuery.camelCase( name ),
hooks = jQuery.cssHooks[ origName ];
name = jQuery.cssProps[ origName ] || origName; // Make sure that we're working with the right name
name = jQuery.camelCase( name );
hooks = jQuery.cssHooks[ name ];
name = jQuery.cssProps[ name ] || name;
// cssFloat needs a special treatment
if ( name === "cssFloat" ) {
name = "float";
}
// If a hook was provided get the computed value from there // If a hook was provided get the computed value from there
if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) { if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
@ -134,7 +140,7 @@ jQuery.extend({
// Otherwise, if a way to get the computed value exists, use that // Otherwise, if a way to get the computed value exists, use that
} else if ( curCSS ) { } else if ( curCSS ) {
return curCSS( elem, name, origName ); return curCSS( elem, name );
} }
}, },
@ -231,7 +237,8 @@ if ( !jQuery.support.opacity ) {
}, },
set: function( elem, value ) { set: function( elem, value ) {
var style = elem.style; var style = elem.style,
currentStyle = elem.currentStyle;
// IE has trouble with opacity if it does not have layout // IE has trouble with opacity if it does not have layout
// Force it by setting the zoom level // Force it by setting the zoom level
@ -241,11 +248,15 @@ if ( !jQuery.support.opacity ) {
var opacity = jQuery.isNaN(value) ? var opacity = jQuery.isNaN(value) ?
"" : "" :
"alpha(opacity=" + value * 100 + ")", "alpha(opacity=" + value * 100 + ")",
filter = style.filter || ""; filter = currentStyle && currentStyle.filter || style.filter || "";
style.filter = ralpha.test(filter) ? style.filter = ralpha.test(filter) ?
filter.replace(ralpha, opacity) : filter.replace(ralpha, opacity) :
<<<<<<< HEAD
style.filter + " " + opacity; style.filter + " " + opacity;
=======
filter + " " + opacity;
>>>>>>> 312df0441b16981dd697d74fcbc1e1f212b47b7e
} }
}; };
} }
@ -273,7 +284,7 @@ jQuery(function() {
}); });
if ( document.defaultView && document.defaultView.getComputedStyle ) { if ( document.defaultView && document.defaultView.getComputedStyle ) {
getComputedStyle = function( elem, newName, name ) { getComputedStyle = function( elem, name ) {
var ret, defaultView, computedStyle; var ret, defaultView, computedStyle;
name = name.replace( rupper, "-$1" ).toLowerCase(); name = name.replace( rupper, "-$1" ).toLowerCase();

17
src/effects.js vendored
View file

@ -121,13 +121,17 @@ jQuery.fn.extend({
var optall = jQuery.speed(speed, easing, callback); var optall = jQuery.speed(speed, easing, callback);
if ( jQuery.isEmptyObject( prop ) ) { if ( jQuery.isEmptyObject( prop ) ) {
return this.each( optall.complete ); return this.each( optall.complete, [ false ] );
} }
return this[ optall.queue === false ? "each" : "queue" ](function() { return this[ optall.queue === false ? "each" : "queue" ](function() {
// XXX 'this' does not always have a nodeName when running the // XXX 'this' does not always have a nodeName when running the
// test suite // test suite
if ( optall.queue === false ) {
jQuery._mark( this );
}
var opt = jQuery.extend({}, optall), p, var opt = jQuery.extend({}, optall), p,
isElement = this.nodeType === 1, isElement = this.nodeType === 1,
hidden = isElement && jQuery(this).is(":hidden"), hidden = isElement && jQuery(this).is(":hidden"),
@ -237,6 +241,10 @@ jQuery.fn.extend({
} }
this.each(function() { this.each(function() {
// clear marker counters if we know they won't be
if ( !gotoEnd ) {
jQuery._unmark( true, this );
}
// go in reverse order so anything added to the queue during the loop is ignored // go in reverse order so anything added to the queue during the loop is ignored
for ( var i = timers.length - 1; i >= 0; i-- ) { for ( var i = timers.length - 1; i >= 0; i-- ) {
if ( timers[i].elem === this ) { if ( timers[i].elem === this ) {
@ -298,10 +306,13 @@ jQuery.extend({
// Queueing // Queueing
opt.old = opt.complete; opt.old = opt.complete;
opt.complete = function() { opt.complete = function( noUnmark ) {
if ( opt.queue !== false ) { if ( opt.queue !== false ) {
jQuery(this).dequeue(); jQuery.dequeue( this );
} else if ( noUnmark !== false ) {
jQuery._unmark( this );
} }
if ( jQuery.isFunction( opt.old ) ) { if ( jQuery.isFunction( opt.old ) ) {
opt.old.call( this ); opt.old.call( this );
} }

View file

@ -24,17 +24,6 @@ jQuery.event = {
return; return;
} }
// TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
// Minor release fix for bug #8018
try {
// For whatever reason, IE has trouble passing the window object
// around, causing it to be cloned in the process
if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
elem = window;
}
}
catch ( e ) {}
if ( handler === false ) { if ( handler === false ) {
handler = returnFalse; handler = returnFalse;
} else if ( !handler ) { } else if ( !handler ) {
@ -574,6 +563,9 @@ jQuery.Event = function( src ) {
} }
} }
// Always ensure a type has been explicitly set
this.type = src.type;
// Events bubbling up the document may have been marked as prevented // Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value. // by a handler lower down the tree; reflect the correct value.
this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
@ -1030,6 +1022,14 @@ jQuery.each(["live", "die"], function( i, name ) {
return this; return this;
} }
if ( name === "die" && !types &&
origSelector && origSelector[0] === "." ) {
context.unbind( origSelector );
return this;
}
if ( data === false || jQuery.isFunction( data ) ) { if ( data === false || jQuery.isFunction( data ) ) {
fn = data || returnFalse; fn = data || returnFalse;
data = undefined; data = undefined;

View file

@ -186,11 +186,13 @@ jQuery.offset = {
// need to be able to calculate position if either top or left is auto and position is either absolute or fixed // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
if ( calculatePosition ) { if ( calculatePosition ) {
curPosition = curElem.position(); curPosition = curElem.position();
curTop = curPosition.top;
curLeft = curPosition.left;
} else {
curTop = parseFloat( curCSSTop ) || 0;
curLeft = parseFloat( curCSSLeft ) || 0;
} }
curTop = calculatePosition ? curPosition.top : parseInt( curCSSTop, 10 ) || 0;
curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0;
if ( jQuery.isFunction( options ) ) { if ( jQuery.isFunction( options ) ) {
options = options.call( elem, i, curOffset ); options = options.call( elem, i, curOffset );
} }

View file

@ -1,27 +1,67 @@
(function( jQuery ) { (function( jQuery ) {
function handleQueueMarkDefer( elem, type, src ) {
var deferDataKey = type + "defer",
queueDataKey = type + "queue",
markDataKey = type + "mark",
defer = jQuery.data( elem, deferDataKey, undefined, true );
if ( defer &&
( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
// Give room for hard-coded callbacks to fire first
// and eventually mark/queue something else on the element
setTimeout( function() {
if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
!jQuery.data( elem, markDataKey, undefined, true ) ) {
jQuery.removeData( elem, deferDataKey, true );
defer.resolve();
}
}, 0 );
}
}
jQuery.extend({ jQuery.extend({
_mark: function( elem, type ) {
if ( elem ) {
type = (type || "fx") + "mark";
jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
}
},
_unmark: function( force, elem, type ) {
if ( force !== true ) {
type = elem;
elem = force;
force = false;
}
if ( elem ) {
type = type || "fx";
var key = type + "mark",
count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
if ( count ) {
jQuery.data( elem, key, count, true );
} else {
jQuery.removeData( elem, key, true );
handleQueueMarkDefer( elem, type, "mark" );
}
}
},
queue: function( elem, type, data ) { queue: function( elem, type, data ) {
if ( !elem ) { if ( elem ) {
return;
}
type = (type || "fx") + "queue"; type = (type || "fx") + "queue";
var q = jQuery._data( elem, type ); var q = jQuery.data( elem, type, undefined, true );
// Speed up dequeue by getting out quickly if this is just a lookup // Speed up dequeue by getting out quickly if this is just a lookup
if ( !data ) { if ( data ) {
return q || [];
}
if ( !q || jQuery.isArray(data) ) { if ( !q || jQuery.isArray(data) ) {
q = jQuery._data( elem, type, jQuery.makeArray(data) ); q = jQuery.data( elem, type, jQuery.makeArray(data), true );
} else { } else {
q.push( data ); q.push( data );
} }
}
return q; return q || [];
}
}, },
dequeue: function( elem, type ) { dequeue: function( elem, type ) {
@ -50,17 +90,7 @@ jQuery.extend({
if ( !queue.length ) { if ( !queue.length ) {
jQuery.removeData( elem, type + "queue", true ); jQuery.removeData( elem, type + "queue", true );
// Look if we have observers and resolve if needed handleQueueMarkDefer( elem, type, "queue" );
if (( defer = jQuery.data( elem, type + "defer", undefined, true ) )) {
// Give room for hard-coded callbacks to fire first
// and eventually add another animation on the element
setTimeout( function() {
if ( !jQuery.data( elem, type + "queue", undefined, true ) ) {
jQuery.removeData( elem, type + "defer", true );
defer.resolve();
}
}, 0 );
}
} }
} }
}); });
@ -75,7 +105,7 @@ jQuery.fn.extend({
if ( data === undefined ) { if ( data === undefined ) {
return jQuery.queue( this[0], type ); return jQuery.queue( this[0], type );
} }
return this.each(function( i ) { return this.each(function() {
var queue = jQuery.queue( this, type, data ); var queue = jQuery.queue( this, type, data );
if ( type === "fx" && queue[0] !== "inprogress" ) { if ( type === "fx" && queue[0] !== "inprogress" ) {
@ -88,7 +118,6 @@ jQuery.fn.extend({
jQuery.dequeue( this, type ); jQuery.dequeue( this, type );
}); });
}, },
// Based off of the plugin by Clint Helfers, with permission. // Based off of the plugin by Clint Helfers, with permission.
// http://blindsignals.com/index.php/2009/07/jquery-delay/ // http://blindsignals.com/index.php/2009/07/jquery-delay/
delay: function( time, type ) { delay: function( time, type ) {
@ -102,11 +131,9 @@ jQuery.fn.extend({
}, time ); }, time );
}); });
}, },
clearQueue: function( type ) { clearQueue: function( type ) {
return this.queue( type || "fx", [] ); return this.queue( type || "fx", [] );
}, },
// Get a promise resolved when queues of a certain type // Get a promise resolved when queues of a certain type
// are emptied (fx is the type by default) // are emptied (fx is the type by default)
promise: function( type, object ) { promise: function( type, object ) {
@ -120,7 +147,8 @@ jQuery.fn.extend({
i = elements.length, i = elements.length,
count = 1, count = 1,
deferDataKey = type + "defer", deferDataKey = type + "defer",
queueDataKey = type + "queue"; queueDataKey = type + "queue",
markDataKey = type + "mark";
function resolve() { function resolve() {
if ( !( --count ) ) { if ( !( --count ) ) {
defer.resolveWith( elements, [ elements ] ); defer.resolveWith( elements, [ elements ] );
@ -128,7 +156,8 @@ jQuery.fn.extend({
} }
while( i-- ) { while( i-- ) {
if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
jQuery.data( elements[ i ], queueDataKey, undefined, true ) && ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) { jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
count++; count++;
tmp.done( resolve ); tmp.done( resolve );

View file

@ -8,6 +8,7 @@ jQuery.support = (function() {
select, select,
opt, opt,
input, input,
marginDiv,
support, support,
fragment, fragment,
body, body,
@ -190,10 +191,12 @@ jQuery.support = (function() {
// Fails in WebKit before Feb 2011 nightlies // Fails in WebKit before Feb 2011 nightlies
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
if ( document.defaultView && document.defaultView.getComputedStyle ) { if ( document.defaultView && document.defaultView.getComputedStyle ) {
div.style.width = "1px"; marginDiv = document.createElement('div');
div.style.marginRight = "0"; marginDiv.style.width = "0";
marginDiv.style.marginRight = "0";
div.appendChild( marginDiv );
support.reliableMarginRight = support.reliableMarginRight =
( parseInt( document.defaultView.getComputedStyle(div).marginRight, 10 ) || 0 ) === 0; ( parseInt( document.defaultView.getComputedStyle( marginDiv ).marginRight, 10 ) || 0 ) === 0;
} }
// Remove the body element we added // Remove the body element we added

View file

@ -73,9 +73,9 @@ jQuery.fn.extend({
}, },
is: function( selector ) { is: function( selector ) {
return !!selector && (typeof selector === "string" ? return !!selector && ( typeof selector === "string" ?
jQuery.filter( selector, this ).length > 0 : jQuery.filter( selector, this ).length > 0 :
this.filter( selector ).length > 0); this.filter( selector ).length > 0 );
}, },
closest: function( selectors, context ) { closest: function( selectors, context ) {
@ -298,13 +298,18 @@ jQuery.extend({
// Implement the identical functionality for filter and not // Implement the identical functionality for filter and not
function winnow( elements, qualifier, keep ) { function winnow( elements, qualifier, keep ) {
// Can't pass null or undefined to indexOf in Firefox 4
// Set to 0 to skip string check
qualifier = qualifier || 0;
if ( jQuery.isFunction( qualifier ) ) { if ( jQuery.isFunction( qualifier ) ) {
return jQuery.grep(elements, function( elem, i ) { return jQuery.grep(elements, function( elem, i ) {
var retVal = !!qualifier.call( elem, i, elem ); var retVal = !!qualifier.call( elem, i, elem );
return retVal === keep; return retVal === keep;
}); });
} else if ( qualifier && qualifier.nodeType ) { } else if ( qualifier.nodeType ) {
return jQuery.grep(elements, function( elem, i ) { return jQuery.grep(elements, function( elem, i ) {
return (elem === qualifier) === keep; return (elem === qualifier) === keep;
}); });

View file

@ -1,5 +1,5 @@
/* for testing opacity set in styles in IE */ /* for testing opacity set in styles in IE */
ol#empty { opacity: 0; filter:Alpha(opacity=0); } ol#empty { opacity: 0; filter:Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff'); }
div#fx-tests h4 { div#fx-tests h4 {
background: red; background: red;

View file

@ -818,7 +818,7 @@ test("jQuery.extend(Object, Object)", function() {
}); });
test("jQuery.each(Object,Function)", function() { test("jQuery.each(Object,Function)", function() {
expect(13); expect(14);
jQuery.each( [0,1,2], function(i, n){ jQuery.each( [0,1,2], function(i, n){
equals( i, n, "Check array iteration" ); equals( i, n, "Check array iteration" );
}); });
@ -850,6 +850,13 @@ test("jQuery.each(Object,Function)", function() {
f[i] = "baz"; f[i] = "baz";
}); });
equals( "baz", f.foo, "Loop over a function" ); equals( "baz", f.foo, "Loop over a function" );
var stylesheet_count = 0;
jQuery.each(document.styleSheets, function(i){
stylesheet_count++;
});
equals(stylesheet_count, 2, "should not throw an error in IE while looping over document.styleSheets and return proper amount");
}); });
test("jQuery.makeArray", function(){ test("jQuery.makeArray", function(){

View file

@ -1,7 +1,7 @@
module("css", { teardown: moduleTeardown }); module("css", { teardown: moduleTeardown });
test("css(String|Hash)", function() { test("css(String|Hash)", function() {
expect(41); expect( 42 );
equals( jQuery("#main").css("display"), "block", "Check for css property \"display\""); equals( jQuery("#main").css("display"), "block", "Check for css property \"display\"");
@ -58,6 +58,9 @@ test("css(String|Hash)", function() {
equals( jQuery("#empty").css("opacity"), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" ); equals( jQuery("#empty").css("opacity"), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" );
jQuery("#empty").css({ opacity: "1" }); jQuery("#empty").css({ opacity: "1" });
equals( jQuery("#empty").css("opacity"), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" ); equals( jQuery("#empty").css("opacity"), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" );
jQuery.support.opacity ?
ok(true, "Requires the same number of tests"):
ok( ~jQuery("#empty")[0].currentStyle.filter.indexOf("gradient"), "Assert setting opacity doesn't overwrite other filters of the stylesheet in IE" );
var div = jQuery("#nothiddendiv"), child = jQuery("#nothiddendivchild"); var div = jQuery("#nothiddendiv"), child = jQuery("#nothiddendivchild");
@ -375,5 +378,19 @@ test("marginRight computed style (bug #3333)", function() {
marginRight: 0 marginRight: 0
}); });
equals($div.css("marginRight"), "0px"); equals($div.css("marginRight"), "0px", "marginRight correctly calculated with a width and display block");
});
test("jQuery.cssProps behavior, (bug #8402)", function() {
var div = jQuery( "<div>" ).appendTo(document.body).css({
position: "absolute",
top: 0,
left: 10
});
jQuery.cssProps.top = "left";
equal( div.css("top"), "10px", "the fixed property is used when accessing the computed style");
div.css("top", "100px");
equal( div[0].style.left, "100px", "the fixed property is used when setting the style");
// cleanup jQuery.cssProps
jQuery.cssProps.top = undefined;
}); });

View file

@ -807,7 +807,7 @@ jQuery.checkState = function(){
jQuery.removeData(this, "olddisplay", true); jQuery.removeData(this, "olddisplay", true);
start(); start();
} };
// Chaining Tests // Chaining Tests
test("Chain fadeOut fadeIn", function() { test("Chain fadeOut fadeIn", function() {

View file

@ -2022,6 +2022,27 @@ test("delegate with submit", function() {
jQuery(document).undelegate(); jQuery(document).undelegate();
}); });
test("undelegate() with only namespaces", function(){
expect(2);
var $delegate = jQuery("#liveHandlerOrder"),
count = 0;
$delegate.delegate("a", "click.ns", function(e) {
count++;
});
jQuery("a", $delegate).eq(0).trigger("click.ns");
equals( count, 1, "delegated click.ns");
$delegate.undelegate(".ns");
jQuery("a", $delegate).eq(1).trigger("click.ns");
equals( count, 1, "no more .ns after undelegate");
});
test("Non DOM element events", function() { test("Non DOM element events", function() {
expect(1); expect(1);

View file

@ -433,7 +433,33 @@ test("offsetParent", function(){
equals( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." ); equals( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
}); });
function testoffset( name, fn ) { test("fractions (see #7730 and #7885)", function() {
expect(2);
jQuery('body').append('<div id="fractions"/>');
var expected = { top: 1000, left: 1000 };
var div = jQuery('#fractions');
div.css({
position: 'absolute',
left: '1000.7432222px',
top: '1000.532325px',
width: 100,
height: 100
});
div.offset(expected);
var result = div.offset();
equals( result.top, expected.top, "Check top" );
equals( result.left, expected.left, "Check left" );
div.remove();
});
function testoffset(name, fn) {
test(name, function() { test(name, function() {
// pause execution for now // pause execution for now

View file

@ -1,10 +1,17 @@
module("queue", { teardown: moduleTeardown }); module("queue", { teardown: moduleTeardown });
test("queue() with other types",function() { test("queue() with other types",function() {
expect(9); expect(11);
var counter = 0; var counter = 0;
var $div = jQuery({}); stop();
var $div = jQuery({}),
defer;
$div.promise("foo").done(function() {
equals( counter, 0, "Deferred for collection with no queue is automatically resolved" );
});
$div $div
.queue("foo",function(){ .queue("foo",function(){
@ -22,6 +29,11 @@ test("queue() with other types",function() {
equals( ++counter, 4, "Dequeuing" ); equals( ++counter, 4, "Dequeuing" );
}); });
defer = $div.promise("foo").done(function() {
equals( counter, 4, "Testing previous call to dequeue in deferred" );
start();
});
equals( $div.queue("foo").length, 4, "Testing queue length" ); equals( $div.queue("foo").length, 4, "Testing queue length" );
$div.dequeue("foo"); $div.dequeue("foo");
@ -74,7 +86,7 @@ test("queue(name) passes in the next item in the queue as a parameter", function
}); });
test("queue() passes in the next item in the queue as a parameter to fx queues", function() { test("queue() passes in the next item in the queue as a parameter to fx queues", function() {
expect(2); expect(3);
stop(); stop();
var div = jQuery({}); var div = jQuery({});
@ -87,11 +99,15 @@ test("queue() passes in the next item in the queue as a parameter to fx queues",
}).queue(function(next) { }).queue(function(next) {
equals(++counter, 2, "Next was called"); equals(++counter, 2, "Next was called");
next(); next();
start();
}).queue("bar", function() { }).queue("bar", function() {
equals(++counter, 3, "Other queues are not triggered by next()") equals(++counter, 3, "Other queues are not triggered by next()")
}); });
jQuery.when( div.promise("fx"), div ).done(function() {
equals(counter, 2, "Deferreds resolved");
start();
});
}); });
test("delay()", function() { test("delay()", function() {
@ -110,7 +126,9 @@ test("delay()", function() {
}); });
test("clearQueue(name) clears the queue", function() { test("clearQueue(name) clears the queue", function() {
expect(1); expect(2);
stop()
var div = jQuery({}); var div = jQuery({});
var counter = 0; var counter = 0;
@ -123,6 +141,11 @@ test("clearQueue(name) clears the queue", function() {
counter++; counter++;
}); });
div.promise("foo").done(function() {
ok( true, "dequeue resolves the deferred" );
start();
});
div.dequeue("foo"); div.dequeue("foo");
equals(counter, 1, "the queue was cleared"); equals(counter, 1, "the queue was cleared");
@ -146,3 +169,81 @@ test("clearQueue() clears the fx queue", function() {
div.removeData(); div.removeData();
}); });
test("_mark() and _unmark()", function() {
expect(1);
var div = {},
$div = jQuery( div );
stop();
jQuery._mark( div, "foo" );
jQuery._mark( div, "foo" );
jQuery._unmark( div, "foo" );
jQuery._unmark( div, "foo" );
$div.promise( "foo" ).done(function() {
ok( true, "No more marks" );
start();
});
});
test("_mark() and _unmark() default to 'fx'", function() {
expect(1);
var div = {},
$div = jQuery( div );
stop();
jQuery._mark( div );
jQuery._mark( div );
jQuery._unmark( div, "fx" );
jQuery._unmark( div );
$div.promise().done(function() {
ok( true, "No more marks" );
start();
});
});
test("promise()", function() {
expect(1);
stop();
var objects = [];
jQuery.each( [{}, {}], function( i, div ) {
var $div = jQuery( div );
$div.queue(function( next ) {
setTimeout( function() {
if ( i ) {
next();
setTimeout( function() {
jQuery._unmark( div );
}, 20 );
} else {
jQuery._unmark( div );
setTimeout( function() {
next();
}, 20 );
}
}, 50 );
}).queue(function( next ) {
next();
});
jQuery._mark( div );
objects.push( $div );
});
jQuery.when.apply( jQuery, objects ).done(function() {
ok( true, "Deferred resolved" );
start();
});
jQuery.each( objects, function() {
this.dequeue();
});
});

View file

@ -72,7 +72,7 @@ test("is(String|undefined)", function() {
}); });
test("is(jQuery)", function() { test("is(jQuery)", function() {
expect(24); expect(23);
ok( jQuery("#form").is( jQuery("form") ), "Check for element: A form is a form" ); ok( jQuery("#form").is( jQuery("form") ), "Check for element: A form is a form" );
ok( !jQuery("#form").is( jQuery("div") ), "Check for element: A form is not a div" ); ok( !jQuery("#form").is( jQuery("div") ), "Check for element: A form is not a div" );
ok( jQuery("#mark").is( jQuery(".blog") ), "Check for class: Expected class 'blog'" ); ok( jQuery("#mark").is( jQuery(".blog") ), "Check for class: Expected class 'blog'" );
@ -83,7 +83,6 @@ test("is(jQuery)", function() {
ok( !jQuery("#en").is( jQuery("[lang=\"de\"]") ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" ); ok( !jQuery("#en").is( jQuery("[lang=\"de\"]") ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" );
ok( jQuery("#text1").is( jQuery("[type=\"text\"]") ), "Check for attribute: Expected attribute type to be 'text'" ); ok( jQuery("#text1").is( jQuery("[type=\"text\"]") ), "Check for attribute: Expected attribute type to be 'text'" );
ok( !jQuery("#text1").is( jQuery("[type=\"radio\"]") ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" ); ok( !jQuery("#text1").is( jQuery("[type=\"radio\"]") ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" );
ok( jQuery("#text2").is( jQuery(":disabled") ), "Check for pseudoclass: Expected to be disabled" );
ok( !jQuery("#text1").is( jQuery(":disabled") ), "Check for pseudoclass: Expected not disabled" ); ok( !jQuery("#text1").is( jQuery(":disabled") ), "Check for pseudoclass: Expected not disabled" );
ok( jQuery("#radio2").is( jQuery(":checked") ), "Check for pseudoclass: Expected to be checked" ); ok( jQuery("#radio2").is( jQuery(":checked") ), "Check for pseudoclass: Expected to be checked" );
ok( !jQuery("#radio1").is( jQuery(":checked") ), "Check for pseudoclass: Expected not checked" ); ok( !jQuery("#radio1").is( jQuery(":checked") ), "Check for pseudoclass: Expected not checked" );