Luke Smith![]()
This patch adds a missing event prefix to the AsyncQueue events, allowing them to be subscribed to from a bubble target.
See the example snippet below for the case where the behavior fails without this patch.
This patch module is only necessary for version 3.3.0.
Apply the patch in the use() statement as long as version 3.3.0 is in use. Remove from the use() statement after upgrading to the subsequent version.
<script src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2011.01.26-20-33'
}).use('async-queue', 'gallery-patch-330-async-queue-bubble', function(Y) {
// The bug would be triggered by any EventTarget extension that is configured with a prefix
// This is commonly seen as the NAME static property of Y.Base subclasses, such as Plugin or Widget.
// In the below case, 'myclass'
Y.MyClass = Y.Base.create('myclass', Y.Base, [], { /* prototype */ }, { /* static properties */ });
var instance = new Y.MyClass(),
queue = new Y.AsyncQueue();
// Make events from queue bubble to instance
queue.addTarget(instance);
// Has worked, and continues to work
queue.on("execute", function (e) {
console.log("Callback executed (logged from AsyncQueue subscription)");
});
// This doesn't work in 3.3.0 without this patch. There was no namespace to identify the event origin
// so the bubble target's prefix would be assumed, but that is a different event. This patch adds the
// prefix 'queue'
instance.on("queue:execute", function (e) {
console.log("Executing a callback from queue (logged from MyClass subscription)");
});
});
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info