Fix for destroy

This commit is contained in:
Sam Potts 2017-11-09 20:54:14 +11:00
parent 4879bea4a0
commit 743c84188e
3 changed files with 18 additions and 11 deletions

2
dist/plyr.js vendored

File diff suppressed because one or more lines are too long

2
dist/plyr.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -922,16 +922,23 @@ class Plyr {
// If it's a soft destroy, make minimal changes // If it's a soft destroy, make minimal changes
if (soft) { if (soft) {
utils.removeElement(this.elements.captions); if (Object.keys(this.elements).length) {
// Remove buttons
if (this.elements.buttons && this.elements.buttons.play) {
Array.from(this.elements.buttons.play).forEach(button => utils.removeElement(button)); Array.from(this.elements.buttons.play).forEach(button => utils.removeElement(button));
}
// Remove others
utils.removeElement(this.elements.captions);
utils.removeElement(this.elements.controls); utils.removeElement(this.elements.controls);
utils.removeElement(this.elements.wrapper); utils.removeElement(this.elements.wrapper);
// Clear for GC // Clear for GC
this.elements.buttons.play = null;
this.elements.captions = null; this.elements.captions = null;
this.elements.controls = null; this.elements.controls = null;
this.elements.buttons.play = null;
this.elements.wrapper = null; this.elements.wrapper = null;
}
// Callback // Callback
if (utils.is.function(callback)) { if (utils.is.function(callback)) {