From: ScottDowne Date: Mon, 13 Jun 2011 19:23:09 +0000 (-0400) Subject: [#519] removePlugin() calling teardown before removal of plugin X-Git-Tag: v0.7^2~42^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=9c98f6c79e38a24a81a903a3ecba3548825dcc13;p=popcorn-js.git [#519] removePlugin() calling teardown before removal of plugin --- diff --git a/popcorn.js b/popcorn.js index d5adf76..ccb26a7 100644 --- a/popcorn.js +++ b/popcorn.js @@ -985,6 +985,8 @@ if ( ( byStart[ idx ] && byStart[ idx ]._natives && byStart[ idx ]._natives.type === name ) && ( byEnd[ idx ] && byEnd[ idx ]._natives && byEnd[ idx ]._natives.type === name ) ) { + byStart[ idx ]._natives._teardown && byStart[ idx ]._natives._teardown.call( obj, byStart[ idx ] ); + byStart.splice( idx, 1 ); byEnd.splice( idx, 1 ); diff --git a/test/popcorn.unit.js b/test/popcorn.unit.js index 099a198..df3ab31 100644 --- a/test/popcorn.unit.js +++ b/test/popcorn.unit.js @@ -1494,7 +1494,7 @@ test("Remove Plugin", function () { p2 = Popcorn("#video"), rlen = Popcorn.registry.length, count = 0, - expects = 21, + expects = 23, interval; function plus() { @@ -1522,17 +1522,23 @@ test("Remove Plugin", function () { }, end: function () { + }, + _teardown: function( options ) { + ok( true, "teardown called on " + options.order + " plugin via removePlugin()" ); + plus(); } }); p.removeme({ start: 2, - end: 3 + end: 3, + order: "first" }); p2.removeme({ start: 2, - end: 3 + end: 3, + order: "second" }); equals( Popcorn.registry.length, 1, "Popcorn.registry.length is 1");