Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
[popup unit tests] detailedEventCascade: Allow event sources to be fu…
Browse files Browse the repository at this point in the history
…nctions which return the actual event source
  • Loading branch information
Gabriel Schulhof committed Aug 8, 2012
1 parent 11ec3a5 commit 922644c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/unit/popup/popup_core.js
Expand Up @@ -41,7 +41,10 @@
// grab one step from the sequence
var fn = seq.shift(),
events = seq.shift(),
self = this;
self = this,
derefSrc = function( src ) {
return ( $.isFunction( src ) ? src() : src );
};

// we're done
if ( fn === undefined ) {
Expand All @@ -58,7 +61,7 @@
$.each( events, function( key, event ) {
if ( newResult[ key ] === undefined ) {
// clean up the unused handler
event.src.unbind( event.event );
derefSrc( event.src ).unbind( event.event );
newResult[ key ] = $.extend( {}, event, { timedOut: true } );
}
});
Expand Down Expand Up @@ -87,7 +90,7 @@
// If it's an event
if ( event.src ) {
// Hook up to the event
event.src.one( event.event, function() {
derefSrc( event.src ).one( event.event, function() {
recordResult( key, event, { timedOut: false, idx: nEventsDone } );
});
}
Expand Down

0 comments on commit 922644c

Please sign in to comment.