hydration.spec.ts — vue Source File
Architecture documentation for hydration.spec.ts, a typescript file in the vue codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 732f2604_e21c_9dd5_2e49_51c82aefe003["hydration.spec.ts"] db9e7bef_009d_3918_6e7d_543a36a38d75["vue"] 732f2604_e21c_9dd5_2e49_51c82aefe003 --> db9e7bef_009d_3918_6e7d_543a36a38d75 973389ac_8625_30a3_53ce_b1b48fae58c5["vnode"] 732f2604_e21c_9dd5_2e49_51c82aefe003 --> 973389ac_8625_30a3_53ce_b1b48fae58c5 22f6e3b3_fd99_35d7_94cf_527e68438cb3["patch"] 732f2604_e21c_9dd5_2e49_51c82aefe003 --> 22f6e3b3_fd99_35d7_94cf_527e68438cb3 ab8fc425_80ef_461f_288a_985447c26d02["constants"] 732f2604_e21c_9dd5_2e49_51c82aefe003 --> ab8fc425_80ef_461f_288a_985447c26d02 style 732f2604_e21c_9dd5_2e49_51c82aefe003 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import Vue from 'vue'
import VNode from 'core/vdom/vnode'
import { patch } from 'web/runtime/patch'
import { SSR_ATTR } from 'shared/constants'
function createMockSSRDOM(innerHTML) {
const dom = document.createElement('div')
dom.setAttribute(SSR_ATTR, 'true')
dom.innerHTML = innerHTML
return dom
}
describe('vdom patch: hydration', () => {
let vnode0
beforeEach(() => {
vnode0 = new VNode('p', { attrs: { id: '1' } }, [
createTextVNode('hello world')
])
patch(null, vnode0)
})
it('should hydrate elements when server-rendered DOM tree is same as virtual DOM tree', () => {
const result: any[] = []
function init(vnode) {
result.push(vnode)
}
function createServerRenderedDOM() {
const root = document.createElement('div')
root.setAttribute(SSR_ATTR, 'true')
const span = document.createElement('span')
root.appendChild(span)
const div = document.createElement('div')
const child1 = document.createElement('span')
const child2 = document.createElement('span')
child1.textContent = 'hi'
child2.textContent = 'ho'
div.appendChild(child1)
div.appendChild(child2)
root.appendChild(div)
return root
}
const node0 = createServerRenderedDOM()
const vnode1 = new VNode('div', {}, [
new VNode('span', {}),
new VNode('div', { hook: { init } }, [
new VNode('span', {}, [
new VNode(undefined, undefined, undefined, 'hi')
]),
new VNode('span', {}, [
new VNode(undefined, undefined, undefined, 'ho')
])
])
])
patch(node0, vnode1)
expect(result.length).toBe(1)
function traverseAndAssert(vnode, element) {
expect(vnode.elm).toBe(element)
if (vnode.children) {
vnode.children.forEach((node, i) => {
// ... (354 more lines)
Domain
Subdomains
Functions
Dependencies
- constants
- patch
- vnode
- vue
Source
Frequently Asked Questions
What does hydration.spec.ts do?
hydration.spec.ts is a source file in the vue codebase, written in typescript. It belongs to the VueCore domain, Observer subdomain.
What functions are defined in hydration.spec.ts?
hydration.spec.ts defines 1 function(s): createMockSSRDOM.
What does hydration.spec.ts depend on?
hydration.spec.ts imports 4 module(s): constants, patch, vnode, vue.
Where is hydration.spec.ts in the architecture?
hydration.spec.ts is located at test/unit/modules/vdom/patch/hydration.spec.ts (domain: VueCore, subdomain: Observer, 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