From 9c98f6c79e38a24a81a903a3ecba3548825dcc13 Mon Sep 17 00:00:00 2001 From: ScottDowne Date: Mon, 13 Jun 2011 15:23:09 -0400 Subject: [PATCH] [#519] removePlugin() calling teardown before removal of plugin --- popcorn.js | 2 ++ test/popcorn.unit.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) 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"); -- 2.43.0