UNPKG

bootstrap-vue-next

Version:

Seamless integration of Vue 3, Bootstrap 5, and TypeScript for modern, type-safe UI development

39 lines (38 loc) 1.32 kB
import "vue"; import { useScrollspy } from "../../composables/useScrollspy/index.mjs"; import { o as omit } from "../../../object-0ALvRU0O.mjs"; import { g as getDirectiveUid } from "../../../utils-BfbvBFtw.mjs"; const bind = (el, binding) => { if (typeof document === "undefined") return; const uid = getDirectiveUid(binding); const elWithScrollspy = el; elWithScrollspy.$__scrollspy = elWithScrollspy.$__scrollspy ?? /* @__PURE__ */ Object.create(null); const existingInstance = elWithScrollspy.$__scrollspy[uid]; if (existingInstance) { existingInstance.cleanup(); } const { arg, value } = binding; const isObject = typeof value === "object" && value !== null; const content = arg ? arg : typeof value === "string" ? value : isObject ? value.content || value.element : null; elWithScrollspy.$__scrollspy[uid] = useScrollspy( content, el, isObject ? omit(value, ["content", "element"]) : {} ); }; const vBScrollspy = { mounted: bind, updated: bind, beforeUnmount(el, binding) { const uid = getDirectiveUid(binding); const elWithScrollspy = el; const instance = elWithScrollspy.$__scrollspy?.[uid]; if (!instance) return; instance.cleanup(); delete elWithScrollspy.$__scrollspy[uid]; } }; export { vBScrollspy }; //# sourceMappingURL=index.mjs.map