]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Use pull request #11366 from ncoden/fix/check-listeners-before-unbind-11360 for v6.5.0
authorNicolas Coden <nicolas@ncoden.fr>
Fri, 6 Jul 2018 20:28:24 +0000 (22:28 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Fri, 6 Jul 2018 20:51:40 +0000 (22:51 +0200)
2c8485f32 fix: prevent removing all listeners by checking them before unbinding

Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
js/foundation.magellan.js
js/foundation.offcanvas.js
js/foundation.reveal.js
js/foundation.sticky.js
js/foundation.tabs.js

index b37ca40f2a367f60e230721b28310a5c3b48dd42..3566b64e8c8fc6d858301ca807a2b556d7bbe35d 100644 (file)
@@ -223,9 +223,8 @@ class Magellan extends Plugin {
       window.location.hash.replace(hash, '');
     }
 
-    $(window)
-      .off('hashchange', this._deepLinkScroll)
-      .off(this.onLoadListener);
+    $(window).off('hashchange', this._deepLinkScroll)
+    if (this.onLoadListener) $(window).off(this.onLoadListener);
   }
 }
 
index 3a155692d8f28db2f1a8a1081dfa8c983eb491d7..a6b65045c82d7b5451c935d49ca8e800221f5a8a 100644 (file)
@@ -447,7 +447,7 @@ class OffCanvas extends Plugin {
     this.close();
     this.$element.off('.zf.trigger .zf.offcanvas');
     this.$overlay.off('.zf.offcanvas');
-    $(window).off(this.onLoadListener);
+    if (this.onLoadListener) $(window).off(this.onLoadListener);
   }
 }
 
index 80444e194c9368bc9a4a3f36e4773fd3aa62a3e8..130c59bdefcef967a6e7dfad69ace72cabe0a3cb 100644 (file)
@@ -502,9 +502,8 @@ class Reveal extends Plugin {
     }
     this.$element.hide().off();
     this.$anchor.off('.zf');
-    $(window)
-      .off(`.zf.reveal:${this.id}`)
-      .off(this.onLoadListener);
+    $(window).off(`.zf.reveal:${this.id}`)
+    if (this.onLoadListener) $(window).off(this.onLoadListener);
 
     if ($('.reveal:visible').length  === 0) {
       this._removeGlobalClasses(); // also remove .is-reveal-open from the html element when there is no opened reveal
index 15bd7b14073f13b44f8b3a453029e1bb27a2d9f4..b9db45f0cbcb7f21648a2d9100acc62fa162a241 100644 (file)
@@ -403,9 +403,8 @@ class Sticky extends Plugin {
     if (this.$anchor && this.$anchor.length) {
       this.$anchor.off('change.zf.sticky');
     }
-    $(window)
-      .off(this.scrollListener)
-      .off(this.onLoadListener);
+    if (this.scrollListener) $(window).off(this.scrollListener)
+    if (this.onLoadListener) $(window).off(this.onLoadListener)
 
     if (this.wasWrapped) {
       this.$element.unwrap();
index 48921ee35f0505d099acccee46dd9c5ff32c0f97..0e2140fc6a5d8e81aeb5e18a52c35286e6889035 100644 (file)
@@ -394,7 +394,9 @@ class Tabs extends Plugin {
       $(window).off('hashchange', this._checkDeepLink);
     }
 
-    $(window).off(this.onLoadListener);
+    if (this.onLoadListener) {
+      $(window).off(this.onLoadListener);
+    }
   }
 }