SSENSE/vue-carousel

Bug: Missing cleanup of resize listener

开放

#385 创建于 2019年3月11日

 (4 条评论) (1 个反应) (0 位负责人)JavaScript (513 个派生)batch import
buggood first issue

仓库指标

星标
 (1,705 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

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.

贡献者指南