From 46e8abbde43ea6b373c48d11ccf5626cc289c1b9 Mon Sep 17 00:00:00 2001 From: rwldrn Date: Mon, 10 Jan 2011 13:41:03 -0500 Subject: [PATCH] [#251] Issue with object addressing of registered exec callbacks --- popcorn.js | 10 +++++++--- test/popcorn.unit.js | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/popcorn.js b/popcorn.js index edc4779..48123cf 100644 --- a/popcorn.js +++ b/popcorn.js @@ -295,14 +295,15 @@ !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); @@ -310,6 +311,7 @@ }; callback.fired = false; + callback.name = guid; this.listen("timeupdate", callback); @@ -463,7 +465,9 @@ 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; } diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 8ffd6fc..a1f131e 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -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(); -- 2.43.0