浏览代码

Fix 'TypeError' on destroy

Prevents "TypeError" (cannot read property 'remove' of null) when $("myElem").vegas('destroy') is called and
'timer' or 'overlay' settings are null or false.
Fausto Bencosme 10 年之前
父节点
当前提交
7af3da8116
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      src/vegas.js

+ 6 - 3
src/vegas.js

@@ -614,9 +614,12 @@
             this.$elmt.find('> .vegas-slide').remove();
             this.$elmt.find('> .vegas-wrapper').clone(true).children().appendTo(this.$elmt);
             this.$elmt.find('> .vegas-wrapper').remove();
-            this.$timer.remove();
-            this.$overlay.remove();
-
+            if (this.settings.timer) {
+              this.$timer.remove();    
+            }
+            if (this.settings.overlay) {
+              this.$overlay.remove();    
+            }
             this.elmt._vegas = null;
         }
     };