chore: replace some type casts and fix variable and filename typos (#93)
This commit is contained in:
parent
23ff681418
commit
fbabae0c0a
@ -39,7 +39,7 @@ export type DirectiveTransform = (
|
|||||||
needRuntime: boolean
|
needRuntime: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// A structural directive transform is a techically a NodeTransform;
|
// A structural directive transform is a technically a NodeTransform;
|
||||||
// Only v-if and v-for fall into this category.
|
// Only v-if and v-for fall into this category.
|
||||||
export type StructuralDirectiveTransform = (
|
export type StructuralDirectiveTransform = (
|
||||||
node: ElementNode,
|
node: ElementNode,
|
||||||
@ -191,11 +191,11 @@ function createTransformContext(
|
|||||||
if (identifiers[id] === undefined) {
|
if (identifiers[id] === undefined) {
|
||||||
identifiers[id] = 0
|
identifiers[id] = 0
|
||||||
}
|
}
|
||||||
;(identifiers[id] as number)++
|
identifiers[id]!++
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeId(id: string) {
|
function removeId(id: string) {
|
||||||
;(context.identifiers[id] as number)--
|
context.identifiers[id]!--
|
||||||
}
|
}
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
@ -191,7 +191,7 @@ export function buildProps(
|
|||||||
let hasDynamicKeys = false
|
let hasDynamicKeys = false
|
||||||
const dynamicPropNames: string[] = []
|
const dynamicPropNames: string[] = []
|
||||||
|
|
||||||
const anaylizePatchFlag = ({ key, value }: Property) => {
|
const analyzePatchFlag = ({ key, value }: Property) => {
|
||||||
if (key.type === NodeTypes.SIMPLE_EXPRESSION && key.isStatic) {
|
if (key.type === NodeTypes.SIMPLE_EXPRESSION && key.isStatic) {
|
||||||
if (value.type !== NodeTypes.SIMPLE_EXPRESSION || !value.isStatic) {
|
if (value.type !== NodeTypes.SIMPLE_EXPRESSION || !value.isStatic) {
|
||||||
const name = key.content
|
const name = key.content
|
||||||
@ -288,10 +288,10 @@ export function buildProps(
|
|||||||
const { props, needRuntime } = directiveTransform(prop, context)
|
const { props, needRuntime } = directiveTransform(prop, context)
|
||||||
if (isArray(props)) {
|
if (isArray(props)) {
|
||||||
properties.push(...props)
|
properties.push(...props)
|
||||||
properties.forEach(anaylizePatchFlag)
|
properties.forEach(analyzePatchFlag)
|
||||||
} else {
|
} else {
|
||||||
properties.push(props)
|
properties.push(props)
|
||||||
anaylizePatchFlag(props)
|
analyzePatchFlag(props)
|
||||||
}
|
}
|
||||||
if (needRuntime) {
|
if (needRuntime) {
|
||||||
runtimeDirectives.push(prop)
|
runtimeDirectives.push(prop)
|
||||||
|
@ -76,7 +76,7 @@ export const transformIf = createStructuralDirectiveTransform(
|
|||||||
// locate the adjacent v-if
|
// locate the adjacent v-if
|
||||||
const siblings = context.parent!.children
|
const siblings = context.parent!.children
|
||||||
const comments = []
|
const comments = []
|
||||||
let i = siblings.indexOf(node as any)
|
let i = siblings.indexOf(node)
|
||||||
while (i-- >= -1) {
|
while (i-- >= -1) {
|
||||||
const sibling = siblings[i]
|
const sibling = siblings[i]
|
||||||
if (__DEV__ && sibling && sibling.type === NodeTypes.COMMENT) {
|
if (__DEV__ && sibling && sibling.type === NodeTypes.COMMENT) {
|
||||||
|
@ -130,9 +130,9 @@ export function track(
|
|||||||
if (depsMap === void 0) {
|
if (depsMap === void 0) {
|
||||||
targetMap.set(target, (depsMap = new Map()))
|
targetMap.set(target, (depsMap = new Map()))
|
||||||
}
|
}
|
||||||
let dep = depsMap.get(key as string | symbol)
|
let dep = depsMap.get(key!)
|
||||||
if (!dep) {
|
if (!dep) {
|
||||||
depsMap.set(key as string | symbol, (dep = new Set()))
|
depsMap.set(key!, (dep = new Set()))
|
||||||
}
|
}
|
||||||
if (!dep.has(effect)) {
|
if (!dep.has(effect)) {
|
||||||
dep.add(effect)
|
dep.add(effect)
|
||||||
@ -170,7 +170,7 @@ export function trigger(
|
|||||||
} else {
|
} else {
|
||||||
// schedule runs for SET | ADD | DELETE
|
// schedule runs for SET | ADD | DELETE
|
||||||
if (key !== void 0) {
|
if (key !== void 0) {
|
||||||
addRunners(effects, computedRunners, depsMap.get(key as string | symbol))
|
addRunners(effects, computedRunners, depsMap.get(key))
|
||||||
}
|
}
|
||||||
// also run for iteration key on ADD | DELETE
|
// also run for iteration key on ADD | DELETE
|
||||||
if (type === OperationTypes.ADD || type === OperationTypes.DELETE) {
|
if (type === OperationTypes.ADD || type === OperationTypes.DELETE) {
|
||||||
|
@ -110,7 +110,7 @@ export interface MethodOptions {
|
|||||||
[key: string]: Function
|
[key: string]: Function
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ExtracComputedReturns<T extends any> = {
|
export type ExtractComputedReturns<T extends any> = {
|
||||||
[key in keyof T]: T[key] extends { get: Function }
|
[key in keyof T]: T[key] extends { get: Function }
|
||||||
? ReturnType<T[key]['get']>
|
? ReturnType<T[key]['get']>
|
||||||
: ReturnType<T[key]>
|
: ReturnType<T[key]>
|
||||||
|
@ -2,7 +2,7 @@ import { ComponentInternalInstance, Data } from './component'
|
|||||||
import { nextTick } from './scheduler'
|
import { nextTick } from './scheduler'
|
||||||
import { instanceWatch } from './apiWatch'
|
import { instanceWatch } from './apiWatch'
|
||||||
import { EMPTY_OBJ, hasOwn, globalsWhitelist } from '@vue/shared'
|
import { EMPTY_OBJ, hasOwn, globalsWhitelist } from '@vue/shared'
|
||||||
import { ExtracComputedReturns } from './apiOptions'
|
import { ExtractComputedReturns } from './apiOptions'
|
||||||
import { UnwrapRef } from '@vue/reactivity'
|
import { UnwrapRef } from '@vue/reactivity'
|
||||||
|
|
||||||
// public properties exposed on the proxy, which is used as the render context
|
// public properties exposed on the proxy, which is used as the render context
|
||||||
@ -26,7 +26,7 @@ export type ComponentPublicInstance<
|
|||||||
} & P &
|
} & P &
|
||||||
UnwrapRef<B> &
|
UnwrapRef<B> &
|
||||||
D &
|
D &
|
||||||
ExtracComputedReturns<C> &
|
ExtractComputedReturns<C> &
|
||||||
M
|
M
|
||||||
|
|
||||||
export const PublicInstanceProxyHandlers = {
|
export const PublicInstanceProxyHandlers = {
|
||||||
|
@ -149,7 +149,7 @@ export function createRenderer<
|
|||||||
} {
|
} {
|
||||||
type HostVNode = VNode<HostNode, HostElement>
|
type HostVNode = VNode<HostNode, HostElement>
|
||||||
type HostVNodeChildren = VNodeChildren<HostNode, HostElement>
|
type HostVNodeChildren = VNodeChildren<HostNode, HostElement>
|
||||||
type HostSuspsenseBoundary = SuspenseBoundary<HostNode, HostElement>
|
type HostSuspenseBoundary = SuspenseBoundary<HostNode, HostElement>
|
||||||
|
|
||||||
const {
|
const {
|
||||||
insert: hostInsert,
|
insert: hostInsert,
|
||||||
@ -171,7 +171,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null = null,
|
anchor: HostNode | null = null,
|
||||||
parentComponent: ComponentInternalInstance | null = null,
|
parentComponent: ComponentInternalInstance | null = null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null = null,
|
parentSuspense: HostSuspenseBoundary | null = null,
|
||||||
isSVG: boolean = false,
|
isSVG: boolean = false,
|
||||||
optimized: boolean = false
|
optimized: boolean = false
|
||||||
) {
|
) {
|
||||||
@ -303,7 +303,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null,
|
anchor: HostNode | null,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean,
|
isSVG: boolean,
|
||||||
optimized: boolean
|
optimized: boolean
|
||||||
) {
|
) {
|
||||||
@ -329,7 +329,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null,
|
anchor: HostNode | null,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean
|
isSVG: boolean
|
||||||
) {
|
) {
|
||||||
const tag = vnode.type as string
|
const tag = vnode.type as string
|
||||||
@ -370,7 +370,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null,
|
anchor: HostNode | null,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean,
|
isSVG: boolean,
|
||||||
start: number = 0
|
start: number = 0
|
||||||
) {
|
) {
|
||||||
@ -392,7 +392,7 @@ export function createRenderer<
|
|||||||
n1: HostVNode,
|
n1: HostVNode,
|
||||||
n2: HostVNode,
|
n2: HostVNode,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean,
|
isSVG: boolean,
|
||||||
optimized: boolean
|
optimized: boolean
|
||||||
) {
|
) {
|
||||||
@ -491,10 +491,10 @@ export function createRenderer<
|
|||||||
|
|
||||||
if (dynamicChildren != null) {
|
if (dynamicChildren != null) {
|
||||||
// children fast path
|
// children fast path
|
||||||
const olddynamicChildren = n1.dynamicChildren!
|
const oldDynamicChildren = n1.dynamicChildren!
|
||||||
for (let i = 0; i < dynamicChildren.length; i++) {
|
for (let i = 0; i < dynamicChildren.length; i++) {
|
||||||
patch(
|
patch(
|
||||||
olddynamicChildren[i],
|
oldDynamicChildren[i],
|
||||||
dynamicChildren[i],
|
dynamicChildren[i],
|
||||||
el,
|
el,
|
||||||
null,
|
null,
|
||||||
@ -522,7 +522,7 @@ export function createRenderer<
|
|||||||
oldProps: any,
|
oldProps: any,
|
||||||
newProps: any,
|
newProps: any,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean
|
isSVG: boolean
|
||||||
) {
|
) {
|
||||||
if (oldProps !== newProps) {
|
if (oldProps !== newProps) {
|
||||||
@ -571,7 +571,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null,
|
anchor: HostNode | null,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean,
|
isSVG: boolean,
|
||||||
optimized: boolean
|
optimized: boolean
|
||||||
) {
|
) {
|
||||||
@ -613,7 +613,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null,
|
anchor: HostNode | null,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean,
|
isSVG: boolean,
|
||||||
optimized: boolean
|
optimized: boolean
|
||||||
) {
|
) {
|
||||||
@ -685,7 +685,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null,
|
anchor: HostNode | null,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean,
|
isSVG: boolean,
|
||||||
optimized: boolean
|
optimized: boolean
|
||||||
) {
|
) {
|
||||||
@ -717,7 +717,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null,
|
anchor: HostNode | null,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean,
|
isSVG: boolean,
|
||||||
optimized: boolean
|
optimized: boolean
|
||||||
) {
|
) {
|
||||||
@ -828,7 +828,7 @@ export function createRenderer<
|
|||||||
suspense.fallbackTree = fallback
|
suspense.fallbackTree = fallback
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveSuspense(suspense: HostSuspsenseBoundary) {
|
function resolveSuspense(suspense: HostSuspenseBoundary) {
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
if (suspense.isResolved) {
|
if (suspense.isResolved) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -861,7 +861,7 @@ export function createRenderer<
|
|||||||
}
|
}
|
||||||
// move content from off-dom container to actual container
|
// move content from off-dom container to actual container
|
||||||
move(subTree as HostVNode, container, anchor)
|
move(subTree as HostVNode, container, anchor)
|
||||||
const el = (vnode.el = (subTree as HostVNode).el as HostNode)
|
const el = (vnode.el = (subTree as HostVNode).el!)
|
||||||
// suspense as the root node of a component...
|
// suspense as the root node of a component...
|
||||||
if (parentComponent && parentComponent.subTree === vnode) {
|
if (parentComponent && parentComponent.subTree === vnode) {
|
||||||
parentComponent.vnode.el = el
|
parentComponent.vnode.el = el
|
||||||
@ -892,7 +892,7 @@ export function createRenderer<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function restartSuspense(suspense: HostSuspsenseBoundary) {
|
function restartSuspense(suspense: HostSuspenseBoundary) {
|
||||||
suspense.isResolved = false
|
suspense.isResolved = false
|
||||||
const {
|
const {
|
||||||
vnode,
|
vnode,
|
||||||
@ -919,7 +919,7 @@ export function createRenderer<
|
|||||||
isSVG,
|
isSVG,
|
||||||
optimized
|
optimized
|
||||||
)
|
)
|
||||||
const el = (vnode.el = (fallbackTree as HostVNode).el as HostNode)
|
const el = (vnode.el = (fallbackTree as HostVNode).el!)
|
||||||
// suspense as the root node of a component...
|
// suspense as the root node of a component...
|
||||||
if (parentComponent && parentComponent.subTree === vnode) {
|
if (parentComponent && parentComponent.subTree === vnode) {
|
||||||
parentComponent.vnode.el = el
|
parentComponent.vnode.el = el
|
||||||
@ -939,7 +939,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null,
|
anchor: HostNode | null,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean,
|
isSVG: boolean,
|
||||||
optimized: boolean
|
optimized: boolean
|
||||||
) {
|
) {
|
||||||
@ -993,7 +993,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null,
|
anchor: HostNode | null,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean
|
isSVG: boolean
|
||||||
) {
|
) {
|
||||||
const instance: ComponentInternalInstance = (initialVNode.component = createComponentInstance(
|
const instance: ComponentInternalInstance = (initialVNode.component = createComponentInstance(
|
||||||
@ -1073,7 +1073,7 @@ export function createRenderer<
|
|||||||
function retryAsyncComponent(
|
function retryAsyncComponent(
|
||||||
instance: ComponentInternalInstance,
|
instance: ComponentInternalInstance,
|
||||||
asyncSetupResult: unknown,
|
asyncSetupResult: unknown,
|
||||||
parentSuspense: HostSuspsenseBoundary,
|
parentSuspense: HostSuspenseBoundary,
|
||||||
isSVG: boolean
|
isSVG: boolean
|
||||||
) {
|
) {
|
||||||
parentSuspense.deps--
|
parentSuspense.deps--
|
||||||
@ -1104,7 +1104,7 @@ export function createRenderer<
|
|||||||
|
|
||||||
function setupRenderEffect(
|
function setupRenderEffect(
|
||||||
instance: ComponentInternalInstance,
|
instance: ComponentInternalInstance,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
initialVNode: HostVNode,
|
initialVNode: HostVNode,
|
||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null,
|
anchor: HostNode | null,
|
||||||
@ -1168,7 +1168,7 @@ export function createRenderer<
|
|||||||
// to child component's vnode
|
// to child component's vnode
|
||||||
updateHOCHostEl(instance, nextTree.el)
|
updateHOCHostEl(instance, nextTree.el)
|
||||||
}
|
}
|
||||||
// upated hook
|
// updated hook
|
||||||
if (instance.u !== null) {
|
if (instance.u !== null) {
|
||||||
queuePostRenderEffect(instance.u, parentSuspense)
|
queuePostRenderEffect(instance.u, parentSuspense)
|
||||||
}
|
}
|
||||||
@ -1207,7 +1207,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null,
|
anchor: HostNode | null,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean,
|
isSVG: boolean,
|
||||||
optimized: boolean = false
|
optimized: boolean = false
|
||||||
) {
|
) {
|
||||||
@ -1311,7 +1311,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
anchor: HostNode | null,
|
anchor: HostNode | null,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean,
|
isSVG: boolean,
|
||||||
optimized: boolean
|
optimized: boolean
|
||||||
) {
|
) {
|
||||||
@ -1358,7 +1358,7 @@ export function createRenderer<
|
|||||||
container: HostElement,
|
container: HostElement,
|
||||||
parentAnchor: HostNode | null,
|
parentAnchor: HostNode | null,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
isSVG: boolean,
|
isSVG: boolean,
|
||||||
optimized: boolean
|
optimized: boolean
|
||||||
) {
|
) {
|
||||||
@ -1464,7 +1464,7 @@ export function createRenderer<
|
|||||||
const s2 = i // next starting index
|
const s2 = i // next starting index
|
||||||
|
|
||||||
// 5.1 build key:index map for newChildren
|
// 5.1 build key:index map for newChildren
|
||||||
const keyToNewIndexMap: Map<any, number> = new Map()
|
const keyToNewIndexMap: Map<string | number, number> = new Map()
|
||||||
for (i = s2; i <= e2; i++) {
|
for (i = s2; i <= e2; i++) {
|
||||||
const nextChild = (c2[i] = normalizeVNode(c2[i]))
|
const nextChild = (c2[i] = normalizeVNode(c2[i]))
|
||||||
if (nextChild.key != null) {
|
if (nextChild.key != null) {
|
||||||
@ -1613,7 +1613,7 @@ export function createRenderer<
|
|||||||
function unmount(
|
function unmount(
|
||||||
vnode: HostVNode,
|
vnode: HostVNode,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
doRemove?: boolean
|
doRemove?: boolean
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
@ -1678,7 +1678,7 @@ export function createRenderer<
|
|||||||
|
|
||||||
function unmountComponent(
|
function unmountComponent(
|
||||||
instance: ComponentInternalInstance,
|
instance: ComponentInternalInstance,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
doRemove?: boolean
|
doRemove?: boolean
|
||||||
) {
|
) {
|
||||||
const { bum, effects, update, subTree, um } = instance
|
const { bum, effects, update, subTree, um } = instance
|
||||||
@ -1724,9 +1724,9 @@ export function createRenderer<
|
|||||||
}
|
}
|
||||||
|
|
||||||
function unmountSuspense(
|
function unmountSuspense(
|
||||||
suspense: HostSuspsenseBoundary,
|
suspense: HostSuspenseBoundary,
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
doRemove?: boolean
|
doRemove?: boolean
|
||||||
) {
|
) {
|
||||||
suspense.isUnmounted = true
|
suspense.isUnmounted = true
|
||||||
@ -1739,7 +1739,7 @@ export function createRenderer<
|
|||||||
function unmountChildren(
|
function unmountChildren(
|
||||||
children: HostVNode[],
|
children: HostVNode[],
|
||||||
parentComponent: ComponentInternalInstance | null,
|
parentComponent: ComponentInternalInstance | null,
|
||||||
parentSuspense: HostSuspsenseBoundary | null,
|
parentSuspense: HostSuspenseBoundary | null,
|
||||||
doRemove?: boolean,
|
doRemove?: boolean,
|
||||||
start: number = 0
|
start: number = 0
|
||||||
) {
|
) {
|
||||||
|
@ -86,7 +86,7 @@ export function handleError(
|
|||||||
) {
|
) {
|
||||||
const contextVNode = instance ? instance.vnode : null
|
const contextVNode = instance ? instance.vnode : null
|
||||||
if (instance) {
|
if (instance) {
|
||||||
let cur: ComponentInternalInstance | null = instance.parent
|
let cur = instance.parent
|
||||||
// the exposed instance is the render proxy to keep it consistent with 2.x
|
// the exposed instance is the render proxy to keep it consistent with 2.x
|
||||||
const exposedInstance = instance.renderProxy
|
const exposedInstance = instance.renderProxy
|
||||||
// in production the hook receives only the error code
|
// in production the hook receives only the error code
|
||||||
|
@ -97,8 +97,8 @@ const blockStack: (VNode[] | null)[] = []
|
|||||||
//
|
//
|
||||||
// disableTracking is true when creating a fragment block, since a fragment
|
// disableTracking is true when creating a fragment block, since a fragment
|
||||||
// always diffs its children.
|
// always diffs its children.
|
||||||
export function openBlock(disableTrackng?: boolean) {
|
export function openBlock(disableTracking?: boolean) {
|
||||||
blockStack.push(disableTrackng ? null : [])
|
blockStack.push(disableTracking ? null : [])
|
||||||
}
|
}
|
||||||
|
|
||||||
let shouldTrack = true
|
let shouldTrack = true
|
||||||
|
@ -65,14 +65,14 @@ function getComponentTrace(): ComponentTraceStack {
|
|||||||
// we can't just use the stack because it will be incomplete during updates
|
// we can't just use the stack because it will be incomplete during updates
|
||||||
// that did not start from the root. Re-construct the parent chain using
|
// that did not start from the root. Re-construct the parent chain using
|
||||||
// instance parent pointers.
|
// instance parent pointers.
|
||||||
const normlaizedStack: ComponentTraceStack = []
|
const normalizeStack: ComponentTraceStack = []
|
||||||
|
|
||||||
while (currentVNode) {
|
while (currentVNode) {
|
||||||
const last = normlaizedStack[0]
|
const last = normalizeStack[0]
|
||||||
if (last && last.vnode === currentVNode) {
|
if (last && last.vnode === currentVNode) {
|
||||||
last.recurseCount++
|
last.recurseCount++
|
||||||
} else {
|
} else {
|
||||||
normlaizedStack.push({
|
normalizeStack.push({
|
||||||
vnode: currentVNode,
|
vnode: currentVNode,
|
||||||
recurseCount: 0
|
recurseCount: 0
|
||||||
})
|
})
|
||||||
@ -82,7 +82,7 @@ function getComponentTrace(): ComponentTraceStack {
|
|||||||
currentVNode = parentInstance && parentInstance.vnode
|
currentVNode = parentInstance && parentInstance.vnode
|
||||||
}
|
}
|
||||||
|
|
||||||
return normlaizedStack
|
return normalizeStack
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatTrace(trace: ComponentTraceStack): string[] {
|
function formatTrace(trace: ComponentTraceStack): string[] {
|
||||||
|
Loading…
Reference in New Issue
Block a user