]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#251] Issue with object addressing of registered exec callbacks
authorrwldrn <waldron.rick@gmail.com>
Mon, 10 Jan 2011 18:41:03 +0000 (13:41 -0500)
committerrwldrn <waldron.rick@gmail.com>
Mon, 10 Jan 2011 18:41:03 +0000 (13:41 -0500)
popcorn.js
test/popcorn.unit.js

index edc47793ea1779030990d5c010411cedf6377199..48123cf92be926390025be1b840fb1553bf28445 100644 (file)
       !fn && ( fn = Popcorn.nop );
       
       
-      var self  = this, 
+      var self = this, 
+          guid = Popcorn.guid( "execCallback" ), 
           callback = function execCallback( event ) {
             
             if ( this.currentTime() >= time && !callback.fired ) {
               
               callback.fired = true;
               
-              this.unlisten("execCallback");
+              this.unlisten("timeupdate", guid );
               
               fn.call(self, event);
               
           };
       
       callback.fired = false;
+      callback.name = guid;
       
       this.listen("timeupdate", callback);
       
       unlisten: function( type, fn ) {
         
         if ( this.data.events[type] && this.data.events[type][fn] ) {
-          this.data.events[type][fn]  = null;
+          
+          delete this.data.events[type][ fn ];
+          
           return this;
         }
       
index 8ffd6fccff8b0299f38df7cdba8b19ed17d0ffc7..a1f131ea274d08ad701c164ad9654b81cea24ace 100644 (file)
@@ -174,7 +174,7 @@ test("exec", function () {
   QUnit.reset();
   
   var popped = Popcorn("#video"),
-      expects = 1, 
+      expects = 2, 
       count = 0;
 
   expect(expects);
@@ -190,7 +190,11 @@ test("exec", function () {
   popped.exec( 4, function () {
     
     
-    ok(true, "exec function");
+    ok(true, "exec callback fired");
+    plus();
+    
+    
+    equal( popped.data.events.timeupdate, null, "exec callback removed");
     plus();
     
   }).currentTime(3).play();