Added a next() shortcut for queues

This commit is contained in:
Yehuda Katz 2009-07-12 14:31:32 +00:00
parent 5b84c7c45c
commit 89b4bc53ca
2 changed files with 22 additions and 1 deletions

View file

@ -92,7 +92,7 @@ jQuery.extend({
fn = queue[0];
if( fn !== undefined )
fn.call(elem);
fn.call(elem, function() { jQuery(elem).dequeue(type); });
}
});

View file

@ -157,4 +157,25 @@ test("queue() with other types",function() {
// Clean up
$div.removeData();
});
test("queue() passes in the next item in the queue as a parameter", function() {
expect(2);
var div = jQuery({});
var counter = 0;
div.queue("foo", function(next) {
equals(++counter, 1, "Dequeueing");
next();
}).queue("foo", function(next) {
equals(++counter, 2, "Next was called");
next();
}).queue("bar", function() {
equals(++counter, 3, "Other queues are not triggered by next()")
});
div.dequeue("foo");
div.removeData();
})