From 89b4bc53ca0ca3d4e5c80b94ce92b09cc34af8ef Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sun, 12 Jul 2009 14:31:32 +0000 Subject: [PATCH] Added a next() shortcut for queues --- src/data.js | 2 +- test/unit/data.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/data.js b/src/data.js index ac069ceea..e429c0de5 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 fa56891fe..3389ef3d7 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(); }) -- 2.39.5