Commit f9a95558 authored by Michael Underwood's avatar Michael Underwood
Browse files

Move popup beforeUnmount handler into component

parent 4ca0a295
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
<script>
import { onMounted, ref, inject, nextTick } from "vue";
import { onMounted, ref, inject, nextTick, onBeforeUnmount } from "vue";
import {
  propsBinder,
  remapEvents,
@@ -21,6 +21,7 @@ export default {

    const useGlobalLeaflet = inject(GLOBAL_LEAFLET_OPT);
    const bindPopup = inject("bindPopup");
    const unbindPopup = inject("unbindPopup");

    const { options, methods } = setupPopup(props, leafletRef, context);

@@ -42,6 +43,11 @@ export default {
      bindPopup({ leafletObject: leafletRef.value });
      nextTick(() => context.emit("ready", leafletRef.value));
    });

    onBeforeUnmount(() => {
      unbindPopup({ leafletObject: leafletRef.value });
    });

    return { root, leafletObject: leafletRef };
  },
  render() {
+0 −7
Original line number Diff line number Diff line
import { onBeforeUnmount, inject } from "vue";
import { popperProps, setupPopper } from "./popper";

export const popupProps = {
@@ -12,11 +11,5 @@ export const popupProps = {
export const setupPopup = (props, leafletRef) => {
  const { options, methods } = setupPopper(props, leafletRef);

  const unbindPopup = inject("unbindPopup");

  onBeforeUnmount(() => {
    unbindPopup();
  });

  return { options, methods };
};