Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dom_element_listener.vue « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b9608a26d91ff443b665fd7f35c4c6007180aca5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<script>
export default {
  props: {
    selector: {
      type: String,
      required: true,
    },
  },
  mounted() {
    this.disposables = Array.from(document.querySelectorAll(this.selector)).flatMap((button) => {
      return Object.entries(this.$listeners).map(([key, value]) => {
        button.addEventListener(key, value);
        return () => {
          button.removeEventListener(key, value);
        };
      });
    });
  },
  destroyed() {
    this.disposables.forEach((x) => {
      x();
    });
  },
  render() {
    return this.$scopedSlots.default?.();
  },
};
</script>