diff options
author | Sam Potts <sam@potts.es> | 2017-11-09 20:54:14 +1100 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2017-11-09 20:54:14 +1100 |
commit | 743c84188e4808c4891d643fb574bcc7ce944aca (patch) | |
tree | ab9ab65258e8c3a0ee298c2eef9dd7134acb3b3c /src/js | |
parent | 4879bea4a038462a2e40d91061e7d7df62deb4f6 (diff) | |
download | plyr-743c84188e4808c4891d643fb574bcc7ce944aca.tar.lz plyr-743c84188e4808c4891d643fb574bcc7ce944aca.tar.xz plyr-743c84188e4808c4891d643fb574bcc7ce944aca.zip |
Fix for destroy
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)) { |