hooks.spec.ts — vue Source File
Architecture documentation for hooks.spec.ts, a typescript file in the vue codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 6f47e873_6214_f584_991d_d58bc63cbc4a["hooks.spec.ts"] b0751bbf_7c2c_dfea_301f_dc2a72bb6e6c["patch"] 6f47e873_6214_f584_991d_d58bc63cbc4a --> b0751bbf_7c2c_dfea_301f_dc2a72bb6e6c a4f22c0d_db48_725a_0132_272983c09232["patch"] 6f47e873_6214_f584_991d_d58bc63cbc4a --> a4f22c0d_db48_725a_0132_272983c09232 f111d70f_7bb3_5a07_23ec_a9cb0556393a["index"] 6f47e873_6214_f584_991d_d58bc63cbc4a --> f111d70f_7bb3_5a07_23ec_a9cb0556393a 20945e0e_c744_c45a_af57_746246c972ef["node-ops"] 6f47e873_6214_f584_991d_d58bc63cbc4a --> 20945e0e_c744_c45a_af57_746246c972ef a9a9ff87_9f66_c824_7b5e_5eb0c304929b["index"] 6f47e873_6214_f584_991d_d58bc63cbc4a --> a9a9ff87_9f66_c824_7b5e_5eb0c304929b f6868225_acf7_afdc_ebd3_15704ddb6566["vnode"] 6f47e873_6214_f584_991d_d58bc63cbc4a --> f6868225_acf7_afdc_ebd3_15704ddb6566 style 6f47e873_6214_f584_991d_d58bc63cbc4a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { patch } from 'web/runtime/patch'
import { createPatchFunction } from 'core/vdom/patch'
import baseModules from 'core/vdom/modules/index'
import * as nodeOps from 'web/runtime/node-ops'
import platformModules from 'web/runtime/modules/index'
import VNode from 'core/vdom/vnode'
const modules = baseModules.concat(platformModules) as any[]
describe('vdom patch: hooks', () => {
let vnode0
beforeEach(() => {
vnode0 = new VNode('p', { attrs: { id: '1' } }, [
createTextVNode('hello world')
])
patch(null, vnode0)
})
it('should call `insert` listener after both parents, siblings and children have been inserted', () => {
const result: any[] = []
function insert(vnode) {
expect(vnode.elm.children.length).toBe(2)
expect(vnode.elm.parentNode.children.length).toBe(3)
result.push(vnode)
}
const vnode1 = new VNode('div', {}, [
new VNode('span', {}, undefined, 'first sibling'),
new VNode('div', { hook: { insert } }, [
new VNode('span', {}, undefined, 'child 1'),
new VNode('span', {}, undefined, 'child 2')
]),
new VNode('span', {}, undefined, 'can touch me')
])
patch(vnode0, vnode1)
expect(result.length).toBe(1)
})
it('should call `prepatch` listener', () => {
const result: any[] = []
function prepatch(oldVnode, newVnode) {
expect(oldVnode).toEqual(vnode1.children[1])
expect(newVnode).toEqual(vnode2.children[1])
result.push(newVnode)
}
const vnode1 = new VNode('div', {}, [
new VNode('span', {}, undefined, 'first sibling'),
new VNode('div', { hook: { prepatch } }, [
new VNode('span', {}, undefined, 'child 1'),
new VNode('span', {}, undefined, 'child 2')
])
])
const vnode2 = new VNode('div', {}, [
new VNode('span', {}, undefined, 'first sibling'),
new VNode('div', { hook: { prepatch } }, [
new VNode('span', {}, undefined, 'child 1'),
new VNode('span', {}, undefined, 'child 2')
])
])
patch(vnode0, vnode1)
patch(vnode1, vnode2)
// ... (319 more lines)
Dependencies
- index
- index
- node-ops
- patch
- patch
- vnode
Source
Frequently Asked Questions
What does hooks.spec.ts do?
hooks.spec.ts is a source file in the vue codebase, written in typescript.
What does hooks.spec.ts depend on?
hooks.spec.ts imports 6 module(s): index, index, node-ops, patch, patch, vnode.
Where is hooks.spec.ts in the architecture?
hooks.spec.ts is located at test/unit/modules/vdom/patch/hooks.spec.ts (directory: test/unit/modules/vdom/patch).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free