diff --git a/src/data.js b/src/data.js index ac069cee..e429c0de 100644 --- a/src/data.js +++ b/src/data.js @@ -92,7 +92,7 @@ jQuery.extend({ fn = queue[0]; if( fn !== undefined ) - fn.call(elem); + fn.call(elem, function() { jQuery(elem).dequeue(type); }); } }); diff --git a/test/unit/data.js b/test/unit/data.js index fa56891f..3389ef3d 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -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(); })