Ticket #2528236 (closed defect)
Reporter Luke Smith |
Opened: 09/9/09 Last modified: 09/29/09 Status: closed Type: defect Resolution: fixed |
Owner Adam Moore |
Target Release: 3.0.0 GA Priority: P3 (normal) |
|---|---|---|---|
| Summary: | Y.on returns ineffective detach handle when subscriptions are defered | ||
| Description: | var handle = Y.on('click', fn, '#notOnThePageYet'); handle.detach(); // does not detach the click handler Y.on returns the "available" event handle I believe. This exposes two issues: |
||
| Type: | defect | Observed in Version: | development master |
| Component: | Event | Severity: | S3 (normal) |
| Assigned To: | Adam Moore | Target Release: | 3.0.0 GA |
| Location: | Library Code | Priority: | P3 (normal) |
| Tags: | Relates To: | ||
| Browsers: | N/A | ||
| URL: | |||
| Test Information: | |||
Change History
|
Posted: 09/10/09
|
|
Posted: 09/10/09
|
|
Posted: 09/16/09
|
|
Posted: 09/16/09
all event listeners configured to return an event handle will always get a single object. Previously, requests that resulted in multiple listeners returned an array. onAvailable and lazy DOM listener detach handles now work as expected. [fixes #2528236]. [fixes #2528239]. |
|
Posted: 09/16/09
all event listeners configured to return an event handle will always get a single object. Previously, requests that resulted in multiple listeners returned an array. onAvailable and lazy DOM listener detach handles now work as expected. [fixes #2528236]. [fixes #2528239]. |
|
Posted: 09/29/09
|
Perhaps rather than return an array of handles when multiple events are hooked up, a single object be returned with a detach method that iterates the array of handles stored in another property. This would allow the use of onAvailable in the Event and special event code to capture the handle returned from the deferred Y.on and modify the handle originally returned.
E.g. in the mouseenter code in the deferral for selector strings resulting in no elements
if (Lang.isString(el)) {
// Need to use Y.all because if el is a string it could be a
// selector that returns a NodeList
element = Y.all(el);
if (element.size() === 0) { // Not found, check using onAvailable
tmpHandle = Event.onAvailable(el, function() {
var newHandle = Y.on.apply(Y, args);
Y.mix(tmpHandle, newHandle); // replace detach handle object properties.
}, Event, true, false);
return tmpHandle;
}
}
This would allow a call to handle.detach() before the elements are found to cancel the pending subscription, but after the elements are found it would properly detach the subscriber(s).