update-listeners.ts — vue Source File
Architecture documentation for update-listeners.ts, a typescript file in the vue codebase. 3 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR a11c2d0a_9676_19da_3fd8_66e9ef25e812["update-listeners.ts"] 02e43f4a_da65_7acd_5a98_0f017554a159["index"] a11c2d0a_9676_19da_3fd8_66e9ef25e812 --> 02e43f4a_da65_7acd_5a98_0f017554a159 156bf2e1_8a13_f22d_5437_54f14bcef8fa["util"] a11c2d0a_9676_19da_3fd8_66e9ef25e812 --> 156bf2e1_8a13_f22d_5437_54f14bcef8fa 907f4994_ea28_43b1_7976_0db9f0e97637["component"] a11c2d0a_9676_19da_3fd8_66e9ef25e812 --> 907f4994_ea28_43b1_7976_0db9f0e97637 1d9d4118_665c_f6c2_cd3e_e1c7a7b6e252["merge-hook.ts"] 1d9d4118_665c_f6c2_cd3e_e1c7a7b6e252 --> a11c2d0a_9676_19da_3fd8_66e9ef25e812 style a11c2d0a_9676_19da_3fd8_66e9ef25e812 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { warn, invokeWithErrorHandling } from 'core/util/index'
import { cached, isUndef, isTrue, isArray } from 'shared/util'
import type { Component } from 'types/component'
const normalizeEvent = cached(
(
name: string
): {
name: string
once: boolean
capture: boolean
passive: boolean
handler?: Function
params?: Array<any>
} => {
const passive = name.charAt(0) === '&'
name = passive ? name.slice(1) : name
const once = name.charAt(0) === '~' // Prefixed last, checked first
name = once ? name.slice(1) : name
const capture = name.charAt(0) === '!'
name = capture ? name.slice(1) : name
return {
name,
once,
capture,
passive
}
}
)
export function createFnInvoker(
fns: Function | Array<Function>,
vm?: Component
): Function {
function invoker() {
const fns = invoker.fns
if (isArray(fns)) {
const cloned = fns.slice()
for (let i = 0; i < cloned.length; i++) {
invokeWithErrorHandling(
cloned[i],
null,
arguments as any,
vm,
`v-on handler`
)
}
} else {
// return handler return value for single handlers
return invokeWithErrorHandling(
fns,
null,
arguments as any,
vm,
`v-on handler`
)
}
}
invoker.fns = fns
return invoker
}
export function updateListeners(
on: Object,
oldOn: Object,
add: Function,
remove: Function,
createOnceHandler: Function,
vm: Component
) {
let name, cur, old, event
for (name in on) {
cur = on[name]
old = oldOn[name]
event = normalizeEvent(name)
if (isUndef(cur)) {
__DEV__ &&
warn(
`Invalid handler for event "${event.name}": got ` + String(cur),
vm
)
} else if (isUndef(old)) {
if (isUndef(cur.fns)) {
cur = on[name] = createFnInvoker(cur, vm)
}
if (isTrue(event.once)) {
cur = on[name] = createOnceHandler(event.name, cur, event.capture)
}
add(event.name, cur, event.capture, event.passive, event.params)
} else if (cur !== old) {
old.fns = cur
on[name] = old
}
}
for (name in oldOn) {
if (isUndef(on[name])) {
event = normalizeEvent(name)
remove(event.name, oldOn[name], event.capture)
}
}
}
Domain
Subdomains
Dependencies
- component
- index
- util
Imported By
Source
Frequently Asked Questions
What does update-listeners.ts do?
update-listeners.ts is a source file in the vue codebase, written in typescript. It belongs to the CoreRuntime domain, VirtualDOM subdomain.
What functions are defined in update-listeners.ts?
update-listeners.ts defines 3 function(s): createFnInvoker, normalizeEvent, updateListeners.
What does update-listeners.ts depend on?
update-listeners.ts imports 3 module(s): component, index, util.
What files import update-listeners.ts?
update-listeners.ts is imported by 1 file(s): merge-hook.ts.
Where is update-listeners.ts in the architecture?
update-listeners.ts is located at src/core/vdom/helpers/update-listeners.ts (domain: CoreRuntime, subdomain: VirtualDOM, directory: src/core/vdom/helpers).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free