Home / File/ events.ts — vue Source File

events.ts — vue Source File

Architecture documentation for events.ts, a typescript file in the vue codebase. 7 imports, 1 dependents.

File typescript WebPlatform RuntimeModules 7 imports 1 dependents 6 functions

Entity Profile

Dependency Diagram

graph LR
  a96f977a_276b_ffab_5b5b_538f5f278c2e["events.ts"]
  156bf2e1_8a13_f22d_5437_54f14bcef8fa["util"]
  a96f977a_276b_ffab_5b5b_538f5f278c2e --> 156bf2e1_8a13_f22d_5437_54f14bcef8fa
  c078cebd_36ee_e879_0a89_19cf4b3ed9a7["index"]
  a96f977a_276b_ffab_5b5b_538f5f278c2e --> c078cebd_36ee_e879_0a89_19cf4b3ed9a7
  02e43f4a_da65_7acd_5a98_0f017554a159["index"]
  a96f977a_276b_ffab_5b5b_538f5f278c2e --> 02e43f4a_da65_7acd_5a98_0f017554a159
  d4806071_afaf_398a_ba47_02caa312757a["model"]
  a96f977a_276b_ffab_5b5b_538f5f278c2e --> d4806071_afaf_398a_ba47_02caa312757a
  768d7987_0d02_bd3d_e5be_d81c1e77a420["scheduler"]
  a96f977a_276b_ffab_5b5b_538f5f278c2e --> 768d7987_0d02_bd3d_e5be_d81c1e77a420
  a4f22c0d_db48_725a_0132_272983c09232["patch"]
  a96f977a_276b_ffab_5b5b_538f5f278c2e --> a4f22c0d_db48_725a_0132_272983c09232
  81ed4f13_7d68_6e21_7425_cf978f68576f["vnode"]
  a96f977a_276b_ffab_5b5b_538f5f278c2e --> 81ed4f13_7d68_6e21_7425_cf978f68576f
  227f73c4_4e20_2188_e5c5_a61fcdcc0b12["index.ts"]
  227f73c4_4e20_2188_e5c5_a61fcdcc0b12 --> a96f977a_276b_ffab_5b5b_538f5f278c2e
  style a96f977a_276b_ffab_5b5b_538f5f278c2e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { isDef, isUndef } from 'shared/util'
import { updateListeners } from 'core/vdom/helpers/index'
import { isIE, isFF, supportsPassive, isUsingMicroTask } from 'core/util/index'
import {
  RANGE_TOKEN,
  CHECKBOX_RADIO_TOKEN
} from 'web/compiler/directives/model'
import { currentFlushTimestamp } from 'core/observer/scheduler'
import { emptyNode } from 'core/vdom/patch'
import type { VNodeWithData } from 'types/vnode'

// normalize v-model event tokens that can only be determined at runtime.
// it's important to place the event as the first in the array because
// the whole point is ensuring the v-model callback gets called before
// user-attached handlers.
function normalizeEvents(on) {
  /* istanbul ignore if */
  if (isDef(on[RANGE_TOKEN])) {
    // IE input[type=range] only supports `change` event
    const event = isIE ? 'change' : 'input'
    on[event] = [].concat(on[RANGE_TOKEN], on[event] || [])
    delete on[RANGE_TOKEN]
  }
  // This was originally intended to fix #4521 but no longer necessary
  // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  /* istanbul ignore if */
  if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
    on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || [])
    delete on[CHECKBOX_RADIO_TOKEN]
  }
}

let target: any

function createOnceHandler(event, handler, capture) {
  const _target = target // save current target element in closure
  return function onceHandler() {
    const res = handler.apply(null, arguments)
    if (res !== null) {
      remove(event, onceHandler, capture, _target)
    }
  }
}

// #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
// implementation and does not fire microtasks in between event propagation, so
// safe to exclude.
const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53)

function add(
  name: string,
  handler: Function,
  capture: boolean,
  passive: boolean
) {
  // async edge case #6566: inner click event triggers patch, event handler
  // attached to outer element during patch, and triggered again. This
  // happens because browsers fire microtask ticks between event propagation.
  // the solution is simple: we save the timestamp when a handler is attached,
  // and the handler would only fire if the event passed to it was fired
// ... (68 more lines)

Domain

Subdomains

Dependencies

  • index
  • index
  • model
  • patch
  • scheduler
  • util
  • vnode

Frequently Asked Questions

What does events.ts do?
events.ts is a source file in the vue codebase, written in typescript. It belongs to the WebPlatform domain, RuntimeModules subdomain.
What functions are defined in events.ts?
events.ts defines 6 function(s): add, createOnceHandler, default.destroy, normalizeEvents, remove, updateDOMListeners.
What does events.ts depend on?
events.ts imports 7 module(s): index, index, model, patch, scheduler, util, vnode.
What files import events.ts?
events.ts is imported by 1 file(s): index.ts.
Where is events.ts in the architecture?
events.ts is located at src/platforms/web/runtime/modules/events.ts (domain: WebPlatform, subdomain: RuntimeModules, directory: src/platforms/web/runtime/modules).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free