Skip to content
Permalink
Browse files

Add clearQueue for clearing non-fx queues

  • Loading branch information
wycats committed Jul 12, 2009
1 parent 89b4bc5 commit d857315967a1cc07b73924bbdf2eb12f4f910c45
Showing with 101 additions and 2 deletions.
  1. +4 −1 src/data.js
  2. +97 −1 test/unit/data.js
@@ -93,7 +93,7 @@ jQuery.extend({

if( fn !== undefined )
fn.call(elem, function() { jQuery(elem).dequeue(type); });
}
},
});

jQuery.fn.extend({
@@ -141,5 +141,8 @@ jQuery.fn.extend({
return this.each(function(){
jQuery.dequeue( this, type );
});
},
clearQueue: function(type){
return this.queue( type, [] );
}
});
@@ -159,7 +159,7 @@ test("queue() with other types",function() {
$div.removeData();
});

test("queue() passes in the next item in the queue as a parameter", function() {
test("queue(name) passes in the next item in the queue as a parameter", function() {
expect(2);

var div = jQuery({});
@@ -178,4 +178,100 @@ test("queue() passes in the next item in the queue as a parameter", function() {
div.dequeue("foo");

div.removeData();
});

expect(1);

var div = jQuery({});
var counter = 0;

div.queue("foo", function(next) {
counter++;
jQuery(this).clearQueue("foo");
next();
}).queue("foo", function(next) {
counter++;
});

div.dequeue("foo");

equals(counter, 1, "the queue was cleared");
test("queue(name) 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();
});

test("queue() passes in the next item in the queue as a parameter to fx queues", function() {
expect(2);

var div = jQuery({});
var counter = 0;

div.queue(function(next) {
equals(++counter, 1, "Dequeueing");
next();
}).queue(function(next) {
equals(++counter, 2, "Next was called");
next();
}).queue(function() {
equals(++counter, 3, "Other queues are not triggered by next()")
});

div.dequeue();

div.removeData();
});

test("clearQueue(name) clears the queue", function() {
expect(1);

var div = jQuery({});
var counter = 0;

div.queue("foo", function(next) {
counter++;
jQuery(this).clearQueue("foo");
next();
}).queue("foo", function(next) {
counter++;
});

div.dequeue("foo");

equals(counter, 1, "the queue was cleared");
});

test("clearQueue() clears the fx queue", function() {
expect(1);

var div = jQuery({});
var counter = 0;

div.queue(function(next) {
counter++;
jQuery(this).clearQueue();
next();
}).queue(function(next) {
counter++;
});

div.dequeue();

equals(counter, 1, "the queue was cleared");
})

0 comments on commit d857315

Please sign in to comment.
You can’t perform that action at this time.