diff options
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/plyr.js | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index 35df7073..2c1f2399 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -922,16 +922,23 @@ class Plyr { // If it's a soft destroy, make minimal changes if (soft) { - utils.removeElement(this.elements.captions); - Array.from(this.elements.buttons.play).forEach(button => utils.removeElement(button)); - utils.removeElement(this.elements.controls); - utils.removeElement(this.elements.wrapper); + 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)); + } - // Clear for GC - this.elements.captions = null; - this.elements.controls = null; - this.elements.buttons.play = null; - this.elements.wrapper = null; + // Remove others + utils.removeElement(this.elements.captions); + utils.removeElement(this.elements.controls); + utils.removeElement(this.elements.wrapper); + + // Clear for GC + this.elements.buttons.play = null; + this.elements.captions = null; + this.elements.controls = null; + this.elements.wrapper = null; + } // Callback if (utils.is.function(callback)) { |