From a77e39f342416da86de9c2cdda12f817c77bfcac Mon Sep 17 00:00:00 2001 From: David LaPalomento Date: Thu, 10 Jul 2014 17:17:53 -0400 Subject: [PATCH] Set this.el_ directly instead of using another variable The flash tech doesn't need to hold onto a reference to the placeholder element after the embed code has been generated. Set this.el_ to the embed code immediately instead of using another property to track it during init. Tested in IE8. --- src/js/media/flash.js | 17 +---------------- test/unit/flash.js | 24 ------------------------ 2 files changed, 1 insertion(+), 40 deletions(-) diff --git a/src/js/media/flash.js b/src/js/media/flash.js index 663f748e1..974001371 100644 --- a/src/js/media/flash.js +++ b/src/js/media/flash.js @@ -244,19 +244,12 @@ vjs.Flash = vjs.MediaTechController.extend({ // If not using iFrame mode, embed as normal object } else { - this.obj = vjs.Flash.embed(options['swf'], placeHolder, flashVars, params, attributes); + this.el_ = vjs.Flash.embed(options['swf'], placeHolder, flashVars, params, attributes); } } }); vjs.Flash.prototype.dispose = function(){ - // the tech is being disposed before onReady has been triggered - // removing the object from the DOM prevents that from firing - // and overwriting the state of the replacement tech - if (this.obj) { - this.obj.parentNode.removeChild(this.obj); - this.obj = null; - } vjs.MediaTechController.prototype.dispose.call(this); }; @@ -408,14 +401,6 @@ vjs.Flash['onReady'] = function(currSwf){ // Reference player on tech element el['player'] = player; - // Update reference to playback technology element - tech.el_ = el; - - // Remove the initialization reference to the tech element - if (tech.obj) { - tech.obj = null; - } - vjs.Flash.checkReady(tech); }; diff --git a/test/unit/flash.js b/test/unit/flash.js index 97574dfa6..a8988f240 100644 --- a/test/unit/flash.js +++ b/test/unit/flash.js @@ -112,27 +112,3 @@ test('dispose removes the object element even before ready fires', function() { strictEqual(tech.el(), null, 'tech el is null'); strictEqual(parentEl.children.length, 0, 'parent el is empty'); }); - -test('dispose removes the object element after ready fires', function() { - var noop = function() {}, - parentEl = document.createElement('div'), - player = { - id: noop, - on: noop, - options_: {} - }, - tech = new vjs.Flash(player, { - 'parentEl': parentEl - }); - - player.tech = tech; - - document.getElementById('qunit-fixture').appendChild(parentEl); - tech.obj['player'] = player; - - vjs.Flash['onReady'](parentEl.children[0].id); - strictEqual(tech.obj, null, 'nulled initialization reference'); - tech.dispose(); - strictEqual(tech.el(), null, 'tech el is null'); - strictEqual(parentEl.children.length, 0, 'parent el is empty'); -});