Skip to content

Commit f16d2f4

Browse files
committed
Use pull request foundation#11366 from ncoden/fix/check-listeners-before-unbind-11360 for v6.5.0
2c8485f fix: prevent removing all listeners by checking them before unbinding Signed-off-by: Nicolas Coden <[email protected]>
1 parent bea1e77 commit f16d2f4

5 files changed

+10
-11
lines changed

js/foundation.magellan.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,8 @@ class Magellan extends Plugin {
223223
window.location.hash.replace(hash, '');
224224
}
225225

226-
$(window)
227-
.off('hashchange', this._deepLinkScroll)
228-
.off(this.onLoadListener);
226+
$(window).off('hashchange', this._deepLinkScroll)
227+
if (this.onLoadListener) $(window).off(this.onLoadListener);
229228
}
230229
}
231230

js/foundation.offcanvas.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class OffCanvas extends Plugin {
447447
this.close();
448448
this.$element.off('.zf.trigger .zf.offcanvas');
449449
this.$overlay.off('.zf.offcanvas');
450-
$(window).off(this.onLoadListener);
450+
if (this.onLoadListener) $(window).off(this.onLoadListener);
451451
}
452452
}
453453

js/foundation.reveal.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,8 @@ class Reveal extends Plugin {
502502
}
503503
this.$element.hide().off();
504504
this.$anchor.off('.zf');
505-
$(window)
506-
.off(`.zf.reveal:${this.id}`)
507-
.off(this.onLoadListener);
505+
$(window).off(`.zf.reveal:${this.id}`)
506+
if (this.onLoadListener) $(window).off(this.onLoadListener);
508507

509508
if ($('.reveal:visible').length === 0) {
510509
this._removeGlobalClasses(); // also remove .is-reveal-open from the html element when there is no opened reveal

js/foundation.sticky.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,8 @@ class Sticky extends Plugin {
403403
if (this.$anchor && this.$anchor.length) {
404404
this.$anchor.off('change.zf.sticky');
405405
}
406-
$(window)
407-
.off(this.scrollListener)
408-
.off(this.onLoadListener);
406+
if (this.scrollListener) $(window).off(this.scrollListener)
407+
if (this.onLoadListener) $(window).off(this.onLoadListener)
409408

410409
if (this.wasWrapped) {
411410
this.$element.unwrap();

js/foundation.tabs.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ class Tabs extends Plugin {
394394
$(window).off('hashchange', this._checkDeepLink);
395395
}
396396

397-
$(window).off(this.onLoadListener);
397+
if (this.onLoadListener) {
398+
$(window).off(this.onLoadListener);
399+
}
398400
}
399401
}
400402

0 commit comments

Comments
 (0)