Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[popup unit tests] detailedEventCascade: Allow event sources to be fu…

…nctions which return the actual event source
  • Loading branch information...
commit 922644cdd1b51619332b5ce7bd3055bf37d7f362 1 parent 11ec3a5
@gabrielschulhof gabrielschulhof authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 tests/unit/popup/popup_core.js
View
9 tests/unit/popup/popup_core.js
@@ -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 ) {
@@ -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 } );
}
});
@@ -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 } );
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.