Skip to content

Commit

Permalink
vue3
Browse files Browse the repository at this point in the history
  • Loading branch information
yihan12 committed Jan 15, 2024
1 parent 61e5c2a commit 978cd72
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions vue2.6-analysis/vue2.6/src/core/vdom/create-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {

// inline hooks to be invoked on component VNodes during patch
const componentVNodeHooks = {
init (vnode: VNodeWithData, hydrating: boolean): ?boolean {
init(vnode: VNodeWithData, hydrating: boolean): ?boolean {
if (
vnode.componentInstance &&
!vnode.componentInstance._isDestroyed &&
Expand All @@ -52,7 +52,7 @@ const componentVNodeHooks = {
}
},

prepatch (oldVnode: MountedComponentVNode, vnode: MountedComponentVNode) {
prepatch(oldVnode: MountedComponentVNode, vnode: MountedComponentVNode) {
const options = vnode.componentOptions
const child = vnode.componentInstance = oldVnode.componentInstance
updateChildComponent(
Expand All @@ -64,7 +64,7 @@ const componentVNodeHooks = {
)
},

insert (vnode: MountedComponentVNode) {
insert(vnode: MountedComponentVNode) {
const { context, componentInstance } = vnode
if (!componentInstance._isMounted) {
componentInstance._isMounted = true
Expand All @@ -84,7 +84,7 @@ const componentVNodeHooks = {
}
},

destroy (vnode: MountedComponentVNode) {
destroy(vnode: MountedComponentVNode) {
const { componentInstance } = vnode
if (!componentInstance._isDestroyed) {
if (!vnode.data.keepAlive) {
Expand All @@ -98,7 +98,7 @@ const componentVNodeHooks = {

const hooksToMerge = Object.keys(componentVNodeHooks)

export function createComponent (
export function createComponent(
Ctor: Class<Component> | Function | Object | void,
data: ?VNodeData,
context: Component,
Expand All @@ -108,7 +108,7 @@ export function createComponent (
if (isUndef(Ctor)) {
return
}

// 实际上取得是vm.$options._base 实际上也是Vue
const baseCtor = context.$options._base

// plain options object: turn it into a constructor
Expand Down Expand Up @@ -205,7 +205,7 @@ export function createComponent (
return vnode
}

export function createComponentInstanceForVnode (
export function createComponentInstanceForVnode(
// we know it's MountedComponentVNode but flow doesn't
vnode: any,
// activeInstance in lifecycle state
Expand All @@ -225,7 +225,7 @@ export function createComponentInstanceForVnode (
return new vnode.componentOptions.Ctor(options)
}

function installComponentHooks (data: VNodeData) {
function installComponentHooks(data: VNodeData) {
const hooks = data.hook || (data.hook = {})
for (let i = 0; i < hooksToMerge.length; i++) {
const key = hooksToMerge[i]
Expand All @@ -237,7 +237,7 @@ function installComponentHooks (data: VNodeData) {
}
}

function mergeHook (f1: any, f2: any): Function {
function mergeHook(f1: any, f2: any): Function {
const merged = (a, b) => {
// flow complains about extra args which is why we use any
f1(a, b)
Expand All @@ -249,10 +249,10 @@ function mergeHook (f1: any, f2: any): Function {

// transform component v-model info (value and callback) into
// prop and event handler respectively.
function transformModel (options, data: any) {
function transformModel(options, data: any) {
const prop = (options.model && options.model.prop) || 'value'
const event = (options.model && options.model.event) || 'input'
;(data.attrs || (data.attrs = {}))[prop] = data.model.value
; (data.attrs || (data.attrs = {}))[prop] = data.model.value
const on = data.on || (data.on = {})
const existing = on[event]
const callback = data.model.callback
Expand Down

0 comments on commit 978cd72

Please sign in to comment.