diff --git a/src/js/media/flash.js b/src/js/media/flash.js index 7b9dd70536..9740013711 100644 --- a/src/js/media/flash.js +++ b/src/js/media/flash.js @@ -244,7 +244,7 @@ vjs.Flash = vjs.MediaTechController.extend({ // If not using iFrame mode, embed as normal object } else { - vjs.Flash.embed(options['swf'], placeHolder, flashVars, params, attributes); + this.el_ = vjs.Flash.embed(options['swf'], placeHolder, flashVars, params, attributes); } } }); @@ -401,9 +401,6 @@ vjs.Flash['onReady'] = function(currSwf){ // Reference player on tech element el['player'] = player; - // Update reference to playback technology element - tech.el_ = el; - vjs.Flash.checkReady(tech); }; @@ -411,6 +408,11 @@ vjs.Flash['onReady'] = function(currSwf){ // If it's not ready, we set a timeout to check again shortly. vjs.Flash.checkReady = function(tech){ + // Stop worrying if the tech has been disposed + if (!tech.el()) { + return; + } + // Check if API property exists if (tech.el().vjs_getProperty) { diff --git a/test/unit/flash.js b/test/unit/flash.js index 982ef1b246..a8988f2405 100644 --- a/test/unit/flash.js +++ b/test/unit/flash.js @@ -96,3 +96,19 @@ test('currentTime is the seek target during seeking', function() { seeking = true; strictEqual(7, tech.currentTime(), 'during seeks the target time is returned'); }); + +test('dispose removes the object element even before ready fires', function() { + var noop = function() {}, + parentEl = document.createElement('div'), + tech = new vjs.Flash({ + id: noop, + on: noop, + options_: {} + }, { + 'parentEl': parentEl + }); + + tech.dispose(); + strictEqual(tech.el(), null, 'tech el is null'); + strictEqual(parentEl.children.length, 0, 'parent el is empty'); +});