Skip to content

Commit

Permalink
Set this.el_ directly instead of using another variable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dmlap committed Jul 10, 2014
1 parent da19fa3 commit a77e39f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 40 deletions.
17 changes: 1 addition & 16 deletions src/js/media/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down Expand Up @@ -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);
};

Expand Down
24 changes: 0 additions & 24 deletions test/unit/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

0 comments on commit a77e39f

Please sign in to comment.