All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.lib.directives.mutate.index.mjs.map Maven / Gradle / Ivy

{"version":3,"file":"index.mjs","names":["mounted","el","binding","modifiers","value","once","immediate","modifierKeys","defaultValue","Object","keys","length","handler","options","attributes","attr","characterData","char","childList","child","subtree","sub","observer","MutationObserver","mutations","arguments","undefined","unmounted","_mutate","instance","$","uid","observe","disconnect","Mutate"],"sources":["../../../src/directives/mutate/index.ts"],"sourcesContent":["// Types\nimport type { DirectiveBinding } from 'vue'\nimport type { MutationOptions } from '@/composables/mutationObserver'\n\nexport interface MutationDirectiveBinding extends Omit {\n  value: MutationCallback | { handler: MutationCallback, options?: MutationObserverInit }\n  modifiers: MutationOptions\n}\n\nfunction mounted (el: HTMLElement, binding: MutationDirectiveBinding) {\n  const modifiers = binding.modifiers || {}\n  const value = binding.value\n  const { once, immediate, ...modifierKeys } = modifiers\n  const defaultValue = !Object.keys(modifierKeys).length\n\n  const { handler, options } = typeof value === 'object'\n    ? value\n    : {\n      handler: value,\n      options: {\n        attributes: modifierKeys?.attr ?? defaultValue,\n        characterData: modifierKeys?.char ?? defaultValue,\n        childList: modifierKeys?.child ?? defaultValue,\n        subtree: modifierKeys?.sub ?? defaultValue,\n      },\n    }\n\n  const observer = new MutationObserver((\n    mutations: MutationRecord[] = [],\n    observer: MutationObserver\n  ) => {\n    handler?.(mutations, observer)\n\n    if (once) unmounted(el, binding)\n  })\n\n  if (immediate) handler?.([], observer)\n\n  el._mutate = Object(el._mutate)\n  el._mutate![binding.instance!.$.uid] = { observer }\n\n  observer.observe(el, options)\n}\n\nfunction unmounted (el: HTMLElement, binding: MutationDirectiveBinding) {\n  if (!el._mutate?.[binding.instance!.$.uid]) return\n\n  el._mutate[binding.instance!.$.uid]!.observer.disconnect()\n  delete el._mutate[binding.instance!.$.uid]\n}\n\nexport const Mutate = {\n  mounted,\n  unmounted,\n}\n\nexport default Mutate\n"],"mappings":"AAAA;;AASA,SAASA,OAAOA,CAAEC,EAAe,E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