SSENSE/vue-carousel

Bug: Missing cleanup of resize listener

Offen

#385 geöffnet am 11.03.2019

 (4 Kommentare) (1 Reaktion) (0 zugewiesene Personen)JavaScript (513 Forks)batch import
buggood first issue

Repository-Metriken

Stars
 (1.705 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Bug Report

Currently in the mounted() hook of Carousel.vue, an event listener is attached to window,

  window.addEventListener(
    "resize",
    debounce(this.onResize, this.refreshRate)
  );

But there is no equivalent removeEventListener call in the beforeDestroy() hook.

  beforeDestroy() {
    this.detachMutationObserver();
    window.removeEventListener("resize", this.getBrowserWidth);
    this.$refs["VueCarousel-inner"].removeEventListener(
      this.transitionstart,
      this.handleTransitionStart
    );
    this.$refs["VueCarousel-inner"].removeEventListener(
      this.transitionend,
      this.handleTransitionEnd
    );
    this.$refs["VueCarousel-wrapper"].removeEventListener(
      this.isTouch ? "touchstart" : "mousedown",
      this.onStart
    );
  }

This results in a buildup of listeners on the window object when a page is navigated to and away from multiple times via routing.

Contributor Guide