aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2017-11-09 20:54:14 +1100
committerSam Potts <sam@potts.es>2017-11-09 20:54:14 +1100
commit743c84188e4808c4891d643fb574bcc7ce944aca (patch)
treeab9ab65258e8c3a0ee298c2eef9dd7134acb3b3c /src
parent4879bea4a038462a2e40d91061e7d7df62deb4f6 (diff)
downloadplyr-743c84188e4808c4891d643fb574bcc7ce944aca.tar.lz
plyr-743c84188e4808c4891d643fb574bcc7ce944aca.tar.xz
plyr-743c84188e4808c4891d643fb574bcc7ce944aca.zip
Fix for destroy
Diffstat (limited to 'src')
-rw-r--r--src/js/plyr.js25
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)) {